nuxt3: __vite_ssr_import_2__.default is not a function
I created an empty Nuxt project
npx nuxi init nuxt-app
then I added a intlify/nuxt3
yarn add -D @intlify/nuxt3
// nuxt.config.ts
import { defineNuxtConfig } from 'nuxt'
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
buildModules: ['@intlify/nuxt3'],
// config for `@intlify/nuxt3`
intlify: {
vueI18n: {
// You can setting same `createI18n` options here !
locale: 'en',
messages: {
en: {
hello: 'Hello'
},
ja: {
hello: 'こんにちは'
}
}
}
}
})
and i get an error
__vite_ssr_import_2__.default is not a function
at /D:/work/nuxt-app/.nuxt/dist/server/server.mjs:10636:60
at fn (/D:/work/nuxt-app/.nuxt/dist/server/server.mjs:412:27)
at Object.callAsync (/D:/work/nuxt-app/node_modules/unctx/dist/index.mjs:41:19)
at callWithNuxt (/D:/work/nuxt-app/.nuxt/dist/server/server.mjs:414:23)
at applyPlugin (/D:/work/nuxt-app/.nuxt/dist/server/server.mjs:369:29)
at Module.applyPlugins (/D:/work/nuxt-app/.nuxt/dist/server/server.mjs:379:11)
at async createNuxtAppServer (/D:/work/nuxt-app/.nuxt/dist/server/server.mjs:46:7)
at async Object.renderToString (/D:/work/nuxt-app/node_modules/vue-bundle-renderer/dist/index.mjs:252:19)
at async /D:/work/nuxt-app/.nuxt/dev/index.mjs:465:20
at async /D:/work/nuxt-app/node_modules/h3/dist/index.mjs:417:19
my package.json
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview"
},
"devDependencies": {
"@intlify/nuxt3": "^0.2.2",
"nuxt": "3.0.0-rc.3"
}
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 40 (2 by maintainers)
Commits related to this issue
- fix : #68 default is not a function problem. — committed to ZCube/nuxt3 by ZCube 2 years ago
- fix : #68 default is not a function problem. — committed to ZCube/nuxt3 by ZCube 2 years ago
afaics the whole shebang of this package can easily be replaced by simply installing https://vue-i18n.intlify.dev/ and adding a nuxt3 plugin by placing a file (e.g. called
i18n.ts
) in theplugins
folder with the following content:Same problem with Nuxt 3 rc.3
It works on me, and I hope helps someone…
Thanks @codeflorist, I went with your approach.
For anyone looking to use
t()
in computed properties, hopefully this will save you some time…Guys I have solved this problem by @erayturan without using vuetify.
Link of my open source project: https://github.com/anburocky3/developer-resources (Feel free to browse the code and check what i used to make it work.)
$t()
is globally accessible in templates but not in script setup. so this should work:for script setup, you can make
useI18n()
accessible via autoload without requiring the import statement via creating a file calleduseI18n
within thecomposables
folder with the following content:Why it is still not solved. 😔
临时解决方法: /node_modules/@intlify/nuxt3/dist/module.mjs 第107行左右
替换为
还有一处没有写入 不影响使用