Closed farahats9 closed 1 week ago
Having the exact same problem. Just started a Nuxt 3 project, then added PrimeVue following the docs, and I can't start it unless I remove PrimeVue.
EDIT: tried installing 4.1.1. Throws the same error. Can only continue by removing PrimeVue from the project.
Yes, I have met the same issue, both under the developement/production mode.
I tried to install 4.2.0, 4.1.1, 4.1.0. All throw the same error.
Cannot access 'Mo' before initialization
at useRuntimeConfig (/E:/Codes/xxx/.nuxt/dev/index.mjs:1:79646)
at /E:/Codes/xxx/.nuxt/dev/index.mjs:1:48326
at ModuleJob.run (node:internal/modules/esm/module_job:268:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:543:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)
Seems the issue caused by invoking the useRuntimeConfig()
at the wrong phase.
Here: https://github.com/primefaces/primevue/blob/705361836a76b17b43c40b03d02b124ff4ed2159/packages/nuxt-module/src/module.ts#L105
I changed to const runtimeConfig = undefined;
, works well.
Cannot use useRuntimeConfig(useEvent());
, it throws Nitro request context is not available. Enable the experimental flag using experimental.asyncContext: true.
@molul I am using patch-package to patch the local-installed @primevue/nuxt-module
line 242 to proceed my works.
Modify the const runtimeConfig = useRuntimeConfig();
to const runtimeConfig = undefined;
.
Can confirm the fix by @wangziling . Strange that it wasn't happening earlier this week, but thankful for the quick workaround to keep moving!
Can confirm the same issue.
same here. Didnt change anything in packages but suddently couldnt run fullstack debug. Love those bugs
I also upgraded to 4.2.1 and I got:
ERROR [worker reload] [worker init] C:/Users/j0rge/Desktop/my-project/.nuxt/dev/index.mjs failed
I needed to downgrade to 4.1.1 and delete my .nuxt folder to make it run without errors. So, @wangziling don't forget also to delete the .nuxt folder, to make it work with 4.1.1
I guess it should be related to nitropack version 2.10, I installed nitropack version 2.9.7 and it works fine.
The problem is the location of the definition of useRuntimeConfig
in the index.mjs file generated in version 2.10.
In version 2.9, the definition of useRuntimeConfig
is at the top (at least it's not used anywhere above it).
In version 2.10, the location of the definition of useRuntimeConfig
is no longer before any use, causing an error when primevue is used.
I'm not sure if this is a nitropack problem or a primevue one, but the current solution seems to be to downgrade the nitropack version to 2 9.7.
It looks like you can't use useRuntimeConfig
in the top level, it has to be wrapped in a function, so it could be a problem with primevue, or nitropack (because of a change in the order of definitions).
This may affect more than just primevue's packages, so I'll try to open an issue there as well.
This is a description of nitro's use of useRuntimeConfig
.
It seems to say that it can only be used in functions that start with define, but it's just that the way nitro builds itself allows useRuntimeConfig
to be defined at the top, so there's no problem.
@kiki-kanri i've just asked on twitter and pi0 said they're already investigating, so it seems to be a nitro problem
Using 4.1.1 (previously deleting .nuxt folder, node_modules folfder and package-lock.json) doesn't fix the issue on my project. This is my package.json:
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev --host",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"reinstall": "rm -rf node_modules .nuxt package-lock.json && npm i"
},
"dependencies": {
"@nuxt/eslint": "^0.6.1",
"@nuxt/icon": "^1.6.1",
"@primevue/themes": "4.1.1",
"husky": "^9.1.6",
"nuxt": "^3.13.2",
"primevue": "4.1.1",
"tailwindcss-primeui": "^0.3.4",
"vue": "latest",
"vue-router": "latest"
},
"devDependencies": {
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@nuxtjs/tailwindcss": "^6.12.2",
"@primevue/nuxt-module": "4.1.1",
"lint-staged": "^15.2.10"
}
}
I get the same error message.
Using 4.1.1 (previously deleting .nuxt folder, node_modules folfder and package-lock.json) doesn't fix the issue on my project. This is my package.json:
{ "name": "nuxt-app", "private": true, "type": "module", "scripts": { "build": "nuxt build", "dev": "nuxt dev --host", "generate": "nuxt generate", "preview": "nuxt preview", "postinstall": "nuxt prepare", "reinstall": "rm -rf node_modules .nuxt package-lock.json && npm i" }, "dependencies": { "@nuxt/eslint": "^0.6.1", "@nuxt/icon": "^1.6.1", "@primevue/themes": "4.1.1", "husky": "^9.1.6", "nuxt": "^3.13.2", "primevue": "4.1.1", "tailwindcss-primeui": "^0.3.4", "vue": "latest", "vue-router": "latest" }, "devDependencies": { "@commitlint/cli": "^19.5.0", "@commitlint/config-conventional": "^19.5.0", "@nuxtjs/tailwindcss": "^6.12.2", "@primevue/nuxt-module": "4.1.1", "lint-staged": "^15.2.10" } }
I get the same error message.
Try install nitropack@2.9.7.
Here are the current solutions.
https://github.com/nuxt-hub/core/issues/363#issuecomment-2453086882
Using 4.1.1 (previously deleting .nuxt folder, node_modules folfder and package-lock.json) doesn't fix the issue on my project. This is my package.json:
{ "name": "nuxt-app", "private": true, "type": "module", "scripts": { "build": "nuxt build", "dev": "nuxt dev --host", "generate": "nuxt generate", "preview": "nuxt preview", "postinstall": "nuxt prepare", "reinstall": "rm -rf node_modules .nuxt package-lock.json && npm i" }, "dependencies": { "@nuxt/eslint": "^0.6.1", "@nuxt/icon": "^1.6.1", "@primevue/themes": "4.1.1", "husky": "^9.1.6", "nuxt": "^3.13.2", "primevue": "4.1.1", "tailwindcss-primeui": "^0.3.4", "vue": "latest", "vue-router": "latest" }, "devDependencies": { "@commitlint/cli": "^19.5.0", "@commitlint/config-conventional": "^19.5.0", "@nuxtjs/tailwindcss": "^6.12.2", "@primevue/nuxt-module": "4.1.1", "lint-staged": "^15.2.10" } }
I get the same error message.
Try install nitropack@2.9.7.
Here are the current solutions.
It worked. Thanks!
Using 4.1.1 (previously deleting .nuxt folder, node_modules folfder and package-lock.json) doesn't fix the issue on my project. This is my package.json:
{ "name": "nuxt-app", "private": true, "type": "module", "scripts": { "build": "nuxt build", "dev": "nuxt dev --host", "generate": "nuxt generate", "preview": "nuxt preview", "postinstall": "nuxt prepare", "reinstall": "rm -rf node_modules .nuxt package-lock.json && npm i" }, "dependencies": { "@nuxt/eslint": "^0.6.1", "@nuxt/icon": "^1.6.1", "@primevue/themes": "4.1.1", "husky": "^9.1.6", "nuxt": "^3.13.2", "primevue": "4.1.1", "tailwindcss-primeui": "^0.3.4", "vue": "latest", "vue-router": "latest" }, "devDependencies": { "@commitlint/cli": "^19.5.0", "@commitlint/config-conventional": "^19.5.0", "@nuxtjs/tailwindcss": "^6.12.2", "@primevue/nuxt-module": "4.1.1", "lint-staged": "^15.2.10" } }
I get the same error message.
I didn't get the same error message since my nuxt project had already been created before. Sorry for that. Please try @kiki-kanri answer
Thank you for all the detailed reports and workarounds 👏 The comments contain very valuable insights. For now, let's wait for a response from NitroPack. Once we hear back, we can decide together on any changes needed.
I'm pinning this issue so we can also gather more user feedback in the meantime.
✅ Nitro 2.10.1 is released with a fix. Recreating lock-file should solve the problem (tested against reproduction).
I've just upgraded to primevue 4.2.1 and there were no errors. Thank you so much @pi0 🫱🏻🫲🏻.
✅ Nitro 2.10.1 is released with a fix. Recreating lock-file should solve the problem (tested against reproduction).
Thanks~ 😉
Wow! Thank you so much for your effort! Nitro man, @pi0 🚀 https://x.com/mertsincan/status/1852881167642436066
✅ Nitro 2.10.1 is released with a fix. Recreating lock-file should solve the problem (tested against reproduction).
Huge thanks!
@pi0 , I had a similar problem ( https://github.com/nuxt/nuxt/issues/29767 ) and this version 2.10.1
of Nitro solved it. However, alerts started to appear several times in the logs:
10:02:28.640 [plugin commonjs--resolver] It appears a plugin has implemented a "resolveId" hook that uses "this.resolve" without forwarding the third "options" parameter of "resolveId". This is problematic as it can lead to wrong module resolutions especially for the node-resolve plugin and in certain cases cause early exit errors for the commonjs plugin.
10:02:28.641 In rare cases, this warning can appear if the same file is both imported and required from the same mixed ES/CommonJS module, in which case it can be ignored.
My package.json
:
"overrides": {
"vue": "^3.5.12",
"nitropack": "2.10.1"
}
Solved in 2.10.2
Excellent! I just tested it and it was resolved
Just delete yarn.lock or npm.lock file and reinstall the dependencies to upgrade the nitro to 2.10.2 or higher version and then the error will disappear
It is not solved, i don't think its because of primevue or other dependency, i am getting this error fully random not after installing a library. and it's basically unsolvable lol. Time to leave nuxt.
It is not solved, i don't think its because of primevue or other dependency, i am getting this error fully random not after installing a library. and it's basically unsolvable lol. Time to leave nuxt.
Did you try setting up a fresh new project? I did and it vanished. I also updated npm and node just in case.
Also with 2.10.2 i continue to have the same error :(
Hey @plcdnl. Could you share your config? Or maybe share your repo
Sorry @j0rgedev my problem was related to @nuxt/sanity
It is not solved, i don't think its because of primevue or other dependency, i am getting this error fully random not after installing a library. and it's basically unsolvable lol. Time to leave nuxt.
Same here ! It's complety random It works, it works, and then suddenly it stops working for no reason!
Are you on WSL with admin rights that change on your machine?
@maximedotair no, i'm on local with fresh nuxt project. It started happening again. Actually it has fix but it doesn't tell you what is the issue, check your syntax at @/server folder if any. Life could be much easier if it would tell where is the damn error lol.
@lpknv I dont think i want to move my code to new project every damn time this happens, there is issue behind but it hides. Rather than telling the error it shutdowns whole project.
Check your server
directory, there should be something wrong. Good luck with finding as it does not tell.
Adding this to package.json
has fixed the issue, at least it told me where is the error.
"overrides": {
"nitropack": "2.9.7"
}
For those who are still having issues. Could you share any reproduction?
I tried Nuxt related projects https://github.com/ZTL-UwU/shadcn-docs-nuxt
, github.com/nuxt-ui-pro/docs
, and the same error occurred
I created a fresh nuxt 3.14 project, installed primevue and it works.
Here is the package.json file
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@primevue/themes": "^4.2.1",
"nuxt": "^3.14.159",
"primevue": "^4.2.1",
"vue": "latest",
"vue-router": "latest"
},
"devDependencies": {
"@primevue/nuxt-module": "^4.2.1"
}
}
Here is the nuxt.config.ts file
import Aura from '@primevue/themes/aura';
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: '2024-04-03',
devtools: { enabled: true },
modules: ['@primevue/nuxt-module'],
primevue: {
options: {
theme: {
preset: Aura,
},
},
},
});
And finally a Button in the app.vue
<template>
<div>
<Button label="Submit" />
</div>
</template>
✅ Nitro 2.10.1 is released with a fix. Recreating lock-file should solve the problem (tested against reproduction).
Work for me, thanks man
I think this happend because nitropack, I just solved this problem by added these lines to my package.json, then recreate my package-lock.json:
"overrides": { "nitropack": "2.9.7" }
After turning the problem upside down, what finally solved the problem was to check that my postgres database used via nuxt in Prisma was online and to generate the models via npx Prisma generate.
@maximedotair yes. I forgot to mention that. I was also having that problem and it's just a nuxt issue since it's not showing the real error; however, if you create a simple nitro app and replicate the issue, it does show the error
Describe the bug
Cannot run the project after adding primevue, the project is just the nuxt starter code and no other packages installed.
nuxt.config.ts
I am using nuxt v3.13.2 vue latest (3.5) and primevue v4.2.1
It gives the error in the title and never loads the app in browser (stuck on the nuxt loading screen)
Reproducer
https://stackblitz.com/edit/nuxt-starter-vhvkfm
PrimeVue version
4.2.1
Vue version
4.x
Language
ALL
Build / Runtime
Nuxt
Browser(s)
All
Steps to reproduce the behavior
No response
Expected behavior
No response