Nuxt 3(bridge)移行で詰まったポイント
エラー内容:
Module parse failed: Identifier 'defineNuxtPlugin' has already been declared
発生時の状況:
capi: true
で発生
export default defineNuxtConfig({
bridge: {
capi: true,
nitro: false
},
})
対処:
babel: {compact: true}
の設定を削除
export default {
build: {
babel: {
compact: true,
},
},
};
エラー内容:
Cannot destructure property '__extends' of '_tslib_js__WEBPACK_IMPORTED_MODULE_0___default.a' as it is undefined
発生時の状況:
sentryモジュールが導入されている場合に発生(nuxt3非対応のため)
modules: [
'@nuxtjs/sentry
]
対処法:
pluginにファイル sentry.client.js
を作成する。グローバルで使用する場合、nuxtApp.provideでプラグインを作成する
import { defineNuxtPlugin } from '#app'
export default defineNuxtPlugin(async (nuxtApp) => {
const sentry = await import('@sentry/vue')
sentry.init({
dsn: process.env.SENTRY_DSN || false, // DSN
app: nuxtApp.vueApp
})
nuxtApp.provide('sentry', sentry)
})
エラー内容:
Cannot read properties of undefined (reading 'resolve')
発生時の状況:
vee-validateのValidationObserverコンポーネントを使用している際に発生
<ValidationObserver v-slot="{ handleSubmit }">
<!-- 応募フォームなど -->
</ValidationObserver>
対処法:
plugins/vee-validate.jsに defineNuxtPlugin
を使用していなかったため、使用
エラー内容:
Cannot start nuxt: Cannot read properties of undefined (reading 'hook')
発生時の状況:
-
nitro: true
時に発生
対処法:
- package-lock.json, node_modulesディレクトリ削除、再インストールで起動が確認できた
エラー内容:
[h3] [unhandled] Cannot read properties of undefined (reading 'indexOf')
発生時の状況:
-
nitro: true
時に発生 -
@nuxtjs/proxy
を使用
対処法:
@nuxtjs/proxy
を削除し、nitro devProxyを nuxt.configに設定