nuxt3 icon indicating copy to clipboard operation
nuxt3 copied to clipboard

After adding `"@intlify/nuxt3"` to `buildModules` in `nuxt.config.ts` there's a Nuxt error

Open PiotrekPKP opened this issue 2 years ago • 25 comments

I installed "@intlify/nuxt3" and added it to my buildModules.

After adding "@intlify/nuxt3" to buildModules in nuxt.config.ts there's a Nuxt error:

__vite_ssr_import_2__.default is not a function

The error occurs even after reinstallation of package and after removing .nuxt directory.

Stacktrace:

at ./.nuxt/dist/server/server.mjs:3590:60
at fn (./.nuxt/dist/server/server.mjs:396:27)
at Object.callAsync (./node_modules/unctx/dist/index.mjs:41:19)
at callWithNuxt (./.nuxt/dist/server/server.mjs:398:23)
at applyPlugin (./.nuxt/dist/server/server.mjs:353:29)
at Module.applyPlugins (./.nuxt/dist/server/server.mjs:363:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async createNuxtAppServer (./.nuxt/dist/server/server.mjs:46:7)
at async renderToString (./node_modules/vue-bundle-renderer/dist/index.mjs:252:19)
at async ./.nuxt/dev/index.mjs:486:20

The line that shows an error is this one:

const loadedOptions = await __vite_ssr_import_2__.default();

This line is in a code block:

const { vueApp: app } = nuxt;
  const loadedOptions = await __vite_ssr_import_2__.default();
  if (!isEmpty(__vite_ssr_import_3__.default)) {
    loadedOptions.messages = __vite_ssr_import_3__.default;
  }
  const i18n = __vite_ssr_import_0__.createI18n({
    legacy: false,
    globalInjection: true,
    locale: "en",
    ...loadedOptions
  });
  app.use(i18n);

PiotrekPKP avatar May 03 '22 09:05 PiotrekPKP

Hey @PiotrekPKP! Are you using Nuxt3 rc2? I'm having the same issue and I'm trying to understand how to solve this

Thanks!

fatrex avatar May 10 '22 12:05 fatrex

Seems like it's related to https://github.com/intlify/nuxt3/issues/64

adriaandotcom avatar May 10 '22 13:05 adriaandotcom

Hey @PiotrekPKP! Are you using Nuxt3 rc2? I'm having the same issue and I'm trying to understand how to solve this

Thanks!

Yes, I'm using Nuxt 3 RC 2

EDIT: It's also broken on RC 3 which came out today

PiotrekPKP avatar May 10 '22 15:05 PiotrekPKP

Seems like it's related to #64

More like #64 is related to this issue ;)

PiotrekPKP avatar May 10 '22 15:05 PiotrekPKP

As this issue is the last one that's open.

Overriding the following packages in package.json will temporarily fix it by forcing rc-1 to be used

  "overrides": {
    "nuxi": "3.0.0-rc.1",
    "nuxt": "3.0.0-rc.1",
    "@nuxt/kit": "3.0.0-rc.1",
    "@nuxt/schema": "3.0.0-rc.1",
    "@nuxt/vite-builder": "3.0.0-rc.1"
  }

LuckyWraptor avatar May 13 '22 13:05 LuckyWraptor

I've created a PR #65 as per @exreplay's findings: https://github.com/intlify/nuxt3/issues/64#issuecomment-1127416063

The patch has been found to work with RC.3

LuckyWraptor avatar May 17 '22 07:05 LuckyWraptor

Merged for v0.2.2

LuckyWraptor avatar May 18 '22 06:05 LuckyWraptor

Merged for v0.2.2

invalid

phcent avatar May 19 '22 05:05 phcent

@kazupon

Rasul1996 avatar May 19 '22 07:05 Rasul1996

Same issue. Do you have an idea? THX

npm install --save-dev @intlify/nuxt3

nuxt.config.ts export default defineNuxtConfig({ ssr: false, // Client-side only rendering (false) buildModules: ['@intlify/nuxt3'] })

error: Uncaught SyntaxError: The requested module '/_nuxt/.nuxt/intlify.vuei18n.options.mjs' does not provide an export named 'default'


"devDependencies": { "@intlify/nuxt3": "^0.2.2", "bulma": "^0.9.4", "nuxt": "3.0.0-rc.4", "sass": "^1.51.0" },

androcado avatar Jun 15 '22 16:06 androcado

@androcado Try adding @intlify/nuxt3 to modules, not buildModules in the nuxt config.

LuckyWraptor avatar Jun 16 '22 06:06 LuckyWraptor

@androcado Try adding @intlify/nuxt3 to modules, not buildModules in the nuxt config.

Thanks. But same issue:

export default defineNuxtConfig({ modules: ['@intlify/nuxt3'], })

error: vite_ssr_import_2.default is not a function

androcado avatar Jun 16 '22 14:06 androcado

Odd, because I can't reproduce it

LuckyWraptor avatar Jun 16 '22 14:06 LuckyWraptor

Odd, because I can't reproduce it

Thank you for your quick support:

npx nuxi init nuxt-app cd nuxt-app npm i npm install --save-dev @intlify/nuxt3

// nuxt.config.ts export default defineNuxtConfig({ modules: ['@intlify/nuxt3'], })

npm run dev // localhost: 3000 -> Uncaught SyntaxError: The requested module '/_nuxt/.nuxt/intlify.vuei18n.options.mjs' does not provide an export named 'default' (at plugin.mjs:3:8)

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.4" } }

npm -v // 6.14.11 node -v // v14.16.0 System: Windows 10

androcado avatar Jun 16 '22 15:06 androcado

@androcado What does your package-lock.json look like?

I've recreated the application using your exact specification, albeit on MacOS image

Would you mind sharing your package-lock please? I'll try to get a windows device to test the same config out

EDIT: Confirmed on Windows using Node v14.16.0 and NPM 6.14.11 image

LuckyWraptor avatar Jun 17 '22 06:06 LuckyWraptor

Here is the package lock file. thx for the support

test1

Unbenanq343nt-2

package-lock.zip

androcado avatar Jun 19 '22 15:06 androcado

I am getting the same error, is there any fix/solutuion ?

kkurt avatar Jun 27 '22 11:06 kkurt

@kkurt @androcado do you guys have the same problem with a fresh project just using the @intlify/nuxt3 package?

I'm having multiple projects running on [email protected] with @intlify/[email protected] and not having any issues.

exreplay avatar Jun 27 '22 11:06 exreplay

@kkurt @androcado do you guys have the same problem with a fresh project just using the @intlify/nuxt3 package?

I'm having multiple projects running on [email protected] with @intlify/[email protected] and not having any issues.

is this on Mac or linux by chance?

LuckyWraptor avatar Jun 28 '22 10:06 LuckyWraptor

@kkurt @androcado do you guys have the same problem with a fresh project just using the @intlify/nuxt3 package? I'm having multiple projects running on [email protected] with @intlify/[email protected] and not having any issues.

is this on Mac or linux by chance?

Yes i have still same issue. I realized that this is about OS. Because I have created fresh new project on stackblitz. There is no problem. But wehen i download same project to my local and run after "npm install", i recieved error. My OS is Win 11.

Stackblitz link : https://stackblitz.com/edit/nuxt-starter-va5flv

kkurt avatar Jun 28 '22 10:06 kkurt

@kkurt What version of node and NPM are you running? My tests also failed when running on Windows.

MacOS and Linux work fine (for me)

LuckyWraptor avatar Jun 28 '22 10:06 LuckyWraptor

@kkurt What version of node and NPM are you running? My tests also failed when running on Windows.

MacOS and Linux work fine (for me)

I also tried with yarn.

NodeJS : 16.15.1 Npm: 8.13.1 Yarn: 1.22.19

kkurt avatar Jun 28 '22 10:06 kkurt

Thanks, with the last update it works for me.

androcado avatar Jul 07 '22 08:07 androcado

image

pnpm run dev and see problem

productdevbook avatar Jul 10 '22 03:07 productdevbook

https://github.com/intlify/nuxt3/issues/72#issuecomment-1184394295

For nuxt3 i18 from community

SVV-team avatar Jul 14 '22 12:07 SVV-team