Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR [worker reload] [worker init] ../.nuxt/dev/index.mjs failed #6712

Closed
farahats9 opened this issue Nov 2, 2024 · 32 comments
Closed

ERROR [worker reload] [worker init] ../.nuxt/dev/index.mjs failed #6712

farahats9 opened this issue Nov 2, 2024 · 32 comments

Comments

@farahats9
Copy link

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

import Aura from '@primevue/themes/aura';

export default defineNuxtConfig({
    modules: [
        '@primevue/nuxt-module'
    ],
    primevue: {
        options: {
            theme: {
                preset: Aura
            }
        }
    }
})

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

@farahats9 farahats9 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 2, 2024
@molul
Copy link

molul commented Nov 2, 2024

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.

@wangziling
Copy link
Contributor

wangziling commented Nov 2, 2024

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)

image

Seems the issue caused by invoking the useRuntimeConfig() at the wrong phase.

Here:

const runtimeConfig = useRuntimeConfig();

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;.

@doug-shontz
Copy link

Can confirm the fix by @wangziling . Strange that it wasn't happening earlier this week, but thankful for the quick workaround to keep moving!

@Noxdor
Copy link

Noxdor commented Nov 2, 2024

Can confirm the same issue.

@Ed1ks
Copy link

Ed1ks commented Nov 2, 2024

same here.
Didnt change anything in packages but suddently couldnt run fullstack debug. Love those bugs

@j0rgedev
Copy link
Contributor

j0rgedev commented Nov 2, 2024

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

@kiki-kanri
Copy link

kiki-kanri commented Nov 2, 2024

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).

image

In version 2.10, the location of the definition of useRuntimeConfig is no longer before any use, causing an error when primevue is used.

image

image

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.

@j0rgedev
Copy link
Contributor

j0rgedev commented Nov 2, 2024

@kiki-kanri i've just asked on twitter and pi0 said they're already investigating, so it seems to be a nitro problem

@molul
Copy link

molul commented Nov 2, 2024

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.

@kiki-kanri
Copy link

kiki-kanri commented Nov 2, 2024

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 [email protected].

Here are the current solutions.

nuxt-hub/core#363 (comment)

@molul
Copy link

molul commented Nov 2, 2024

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 [email protected].

Here are the current solutions.

nuxt-hub/core#363 (comment)

It worked. Thanks!

@j0rgedev
Copy link
Contributor

j0rgedev commented Nov 2, 2024

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

@mertsincan
Copy link
Member

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.

@mertsincan mertsincan added Resolution: Help Wanted Issue or pull request requires extra help and feedback Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 2, 2024
@mertsincan mertsincan pinned this issue Nov 2, 2024
@pi0
Copy link

pi0 commented Nov 2, 2024

✅ Nitro 2.10.1 is released with a fix. Recreating lock-file should solve the problem (tested against reproduction).

@j0rgedev
Copy link
Contributor

j0rgedev commented Nov 2, 2024

I've just upgraded to primevue 4.2.1 and there were no errors. Thank you so much @pi0 🫱🏻‍🫲🏻.

@wangziling
Copy link
Contributor

✅ Nitro 2.10.1 is released with a fix. Recreating lock-file should solve the problem (tested against reproduction).

Thanks~ 😉

@mertsincan
Copy link
Member

mertsincan commented Nov 3, 2024

Wow! Thank you so much for your effort! Nitro man, @pi0 🚀
https://x.com/mertsincan/status/1852881167642436066

@mertsincan mertsincan removed Resolution: Help Wanted Issue or pull request requires extra help and feedback Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team labels Nov 3, 2024
@lpknv
Copy link

lpknv commented Nov 3, 2024

✅ Nitro 2.10.1 is released with a fix. Recreating lock-file should solve the problem (tested against reproduction).

Huge thanks!

@luizzappa
Copy link

@pi0 , I had a similar problem ( nuxt/nuxt#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"
  }

@pi0
Copy link

pi0 commented Nov 3, 2024

Solved in 2.10.2

@luizzappa
Copy link

Excellent! I just tested it and it was resolved

@ejkgmea
Copy link

ejkgmea commented Nov 4, 2024

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

@arshx86
Copy link

arshx86 commented Nov 5, 2024

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.

@lpknv
Copy link

lpknv commented Nov 5, 2024

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.

@plcdnl
Copy link

plcdnl commented Nov 6, 2024

Also with 2.10.2 i continue to have the same error :(

@j0rgedev
Copy link
Contributor

j0rgedev commented Nov 6, 2024

Hey @plcdnl. Could you share your config? Or maybe share your repo

@plcdnl
Copy link

plcdnl commented Nov 7, 2024

Sorry @j0rgedev my problem was related to @nuxt/sanity

@maximedotair
Copy link

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?

@arshx86
Copy link

arshx86 commented Nov 7, 2024

@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"
}

@j0rgedev
Copy link
Contributor

j0rgedev commented Nov 7, 2024

For those who are still having issues. Could you share any reproduction?

@llds66
Copy link

llds66 commented Nov 8, 2024

I tried Nuxt related projects https://github.com/ZTL-UwU/shadcn-docs-nuxt, github.com/nuxt-ui-pro/docs, and the same error occurred
image

@lpknv
Copy link

lpknv commented Nov 11, 2024

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests