i18n: ERROR Cannot resolve vue-i18n on pnpm! please install it on 'node_modules'

Environment

Reproduction

It’s monorepo on pnpm with .npmrc at root path, if without this file, nuxt3 cannot work:

shamefully-hoist=true
strict-peer-dependencies=false

Describe the bug

In my monorepo project, when I add "@nuxtjs/i18n": "8.0.0-beta.10" to package.json for my nuxt3 project, I can neither install deps nor run dev. It told me :

 ERROR  Cannot resolve vue-i18n on pnpm! please install it on 'node_modules'
│   at tryResolve (/D:/GitRepo/serverless/frontend-monorepo/node_modules/.pnpm/@nuxtjs+i18n@8.0.0-beta.10_vue@3.2.47/node_modules/@nuxtjs/i18n/dist/module.mjs:116:9)
│   at async setupAlias (/D:/GitRepo/serverless/frontend-monorepo/node_modules/.pnpm/@nuxtjs+i18n@8.0.0-beta.10_vue@3.2.47/node_modules/@nuxtjs/i18n/dist/module.mjs:215:38)
│   at async setup (/D:/GitRepo/serverless/frontend-monorepo/node_modules/.pnpm/@nuxtjs+i18n@8.0.0-beta.10_vue@3.2.47/node_modules/@nuxtjs/i18n/dist/module.mjs:964:5)
│   at async normalizedModule (/D:/GitRepo/serverless/frontend-monorepo/node_modules/.pnpm/@nuxt+kit@3.4.3/node_modules/@nuxt/kit/dist/index.mjs:170:17)
│   at async installModule (/D:/GitRepo/serverless/frontend-monorepo/node_modules/.pnpm/@nuxt+kit@3.4.2/node_modules/@nuxt/kit/dist/index.mjs:450:95)
│   at async initNuxt (/D:/GitRepo/serverless/frontend-monorepo/node_modules/.pnpm/nuxt@3.4.2_@types+node@18.16.5_sass@1.62.0_typescript@5.0.4/node_modules/nuxt/dist/index.mjs:2619:7)   
│   at async loadNuxt (/D:/GitRepo/serverless/frontend-monorepo/node_modules/.pnpm/nuxt@3.4.2_@types+node@18.16.5_sass@1.62.0_typescript@5.0.4/node_modules/nuxt/dist/index.mjs:2680:5)   
│   at async loadNuxt (/D:/GitRepo/serverless/frontend-monorepo/node_modules/.pnpm/@nuxt+kit@3.4.3/node_modules/@nuxt/kit/dist/index.mjs:545:19)
│   at async Object.invoke (/D:/GitRepo/serverless/frontend-monorepo/node_modules/.pnpm/nuxi@3.4.2/node_modules/nuxi/dist/chunks/prepare.mjs:31:18)
│   at async _main (/D:/GitRepo/serverless/frontend-monorepo/node_modules/.pnpm/nuxi@3.4.2/node_modules/nuxi/dist/cli.mjs:48:20)

Additional context

No response

Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 32

Most upvoted comments

shamefully-hoist=true did the trick for me

Forgot mention that i had latest pnpm(8.8.0). And in my .npmrc i had shamefully hoisted always on.

Another way to fix it is to add install package on the root level package.json.

The last workaround is a long way and i recommend add it to script if you decide to go this path.

  1. If you have @nuxtjs/i18n installed. Remove it

  2. Install the nuxt packages as usual.

  3. Install @nutxjs/i18n with shameful option as it says im github repo.

Note run this from the folder were nuxt is. If you fail do this just start from step 1 again.

Also if postinstall from the package fails ignore it. Important is that last step works.

  1. Navigate to the project folder were you have nuxt config file.

From there run pnpm nuxi prepare.

Note when you remove .nuxt or add new package you will need to redo this. It is a pain and far from a good solution. But its the best i got, others have tried it and confirmed that it works for them to.

Thats why i recommend write a script for it.

But as i said earlier after latest nuxt version (7.4.0 i think) and rc5 it just went away. The folks that tried my earlier workaround confirmed it went away from them to.

Last but not least if you use private registry make sure it is also working properly. Some registry does not work in the best way with pnpm or other pkg managers.

"@nuxtjs/i18n": "8.0.0-rc.4"

This problem still exists, has it not been fixed yet?

seems to be fixed for me, get latest nuxt and rc5 instead.

"@nuxtjs/i18n": "8.0.0-rc.4"

This problem still exists, has it not been fixed yet?

For people using pnpm and getting issues when shared-workspace-lockfile=false is added to the root .npmrc file.

The best solution we came up with was to to add these packages to the package.json file of our nuxt app.

"@intlify/message-compiler": "9.4.1",
"@intlify/shared": "9.4.1",
"@intlify/vue-i18n-bridge": "1.0.1",
"@intlify/vue-router-bridge": "1.0.1",
"vue-i18n": "9.4.1",
"vue-i18n-routing": "1.1.1",

Still no fix?

Adding a .npmrc with shared-workspace-lockfile=false to my root folder works!

Also, you can see if placing shared-workspace-lockfile=false into a root .pnpmrc makes .pnpmrcs in subdirectories be respected or if any other option fits your needs. Be sure to post here if you find what’s working for you so others can find a solution as well! 😃