i18n: ERROR Cannot resolve vue-i18n on pnpm! please install it on 'node_modules'
Environment
- Operating System: Windows_NT
- Node Version: v18.16.0
- Nuxt Version: 3.4.2
- Nitro Version: 2.4.0
- Package Manager: pnpm@8.4.0
- Builder: vite
- User Config: modules, vite, css, imports, pinia, sitemap, app, ignore, telemetry, appConfig, devServer, nitro
- Runtime Modules: @nuxtjs/tailwindcss@6.6.6, @pinia/nuxt@0.4.8, @pinia-plugin-persistedstate/nuxt@1.1.1, @element-plus/nuxt@1.0.4, @nuxtjs/robots@3.0.0, nuxt-simple-sitemap@2.4.11, @nuxtjs/i18n@8.0.0-beta.10
- Build Modules: -
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
shamefully-hoist=truedid the trick for meForgot 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.
If you have
@nuxtjs/i18ninstalled. Remove itInstall the nuxt packages as usual.
Install
@nutxjs/i18nwith 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.
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.
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=falseis added to the root.npmrcfile.The best solution we came up with was to to add these packages to the
package.jsonfile of our nuxt app.Still no fix?
Adding a
.npmrcwithshared-workspace-lockfile=falseto my root folder works!Also, you can see if placing
shared-workspace-lockfile=falseinto a root.pnpmrcmakes.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! 😃