framework icon indicating copy to clipboard operation
framework copied to clipboard

Cannot start nuxt: Cannot find module '@nuxt/vite-builder'

Open loremru opened this issue 3 years ago • 6 comments

Environment

Nuxt CLI v3.0.0-rc.6
RootDir: C:\Users\Ilya\Desktop\nuxt-app
Nuxt project info:


  • Operating System: Windows_NT
  • Node Version: v16.15.0
  • Nuxt Version: 3.0.0-rc.6
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: ssr, bridge, buildModules, css, windicss, build
  • Runtime Modules: -
  • Build Modules: [email protected]

Reproduction

https://github.com/loremru/nuxt-bug

Describe the bug

ERROR Cannot start nuxt: Cannot find module '@nuxt/vite-builder'
Require stack:

  • C:\Users\Ilya\Desktop\nuxt-app\index.js

image

Additional context

on majestic-ui version 0.0.83-13 its ok. But on latest versions there are nothing changed, only yarn version. Also latest versions works on clear vite.js

Logs

No response

loremru avatar Jul 27 '22 11:07 loremru

Just curious, what happens if you add the @nuxt/vite-builder module?

I got another error so I stopped trying fixing this myself because I could not find the root cause🤷

Harm-Nullix avatar Jul 27 '22 12:07 Harm-Nullix

Please remove nuxt-vite dependency (it is for Nuxt 20, node_modules and yarn.lock. Also as workaround, as @HarmNullix mentioned, directly add @nuxt/vite-builder dependency and reinstall with yarn install. It should fix the problem.

This is a strange behavior of yarn only with some dependencies hoisting @nuxt/vite-builder to node_modules/nuxt/node_modules/@nuxt/vite-builder (which is inaccessible from node_modules/@nuxt/kit).

pi0 avatar Jul 27 '22 12:07 pi0

Please remove nuxt-vite dependency (it is for Nuxt 20, node_modules and yarn.lock. Also as workaround, as @HarmNullix mentioned, directly add @nuxt/vite-builder dependency and reinstall with yarn install. It should fix the problem.

This is a strange behavior of yarn only with some dependencies hoisting @nuxt/vite-builder to node_modules/nuxt/node_modules/@nuxt/vite-builder (which is inaccessible from node_modules/@nuxt/kit).

After all manipulations I got another error as @HarmNullix said: [h3] [unhandled] H3Error: document is not defined

image

loremru avatar Jul 27 '22 12:07 loremru

Hmm, I'm afraid this issue is not related to yarn. Seems one of the dependencies you are using is not compatible with server-side rendering. Would you mind to update your repo or create a branch with dependency fix? Would be happy to help investigating that :)

pi0 avatar Jul 27 '22 13:07 pi0

Hmm, I'm afraid this issue is not related to yarn. Seems one of the dependencies you are using is not compatible with server-side rendering. Would you mind to update your repo or create a branch with dependency fix? Would be happy to help investigating that :)

https://github.com/loremru/nuxt-bug/tree/try-to-fix

loremru avatar Jul 27 '22 13:07 loremru

Is there any news? @pi0

loremru avatar Aug 01 '22 03:08 loremru

its a vue bug project and majestic-ui were need to update vue/vite packages

loremru avatar Aug 15 '22 08:08 loremru

Reopening because there is something we can improve within Nuxt. @nuxt/vite-builder is being imported from rootDir (https://github.com/nuxt/framework/blob/ff924468ea22258685a37c19f64fcc694d01c959/packages/nuxt/src/core/builder.ts#L60) while we shall include parent nuxt package into the search path to handle situations when package manager decides to not hoist the dependency.

pi0 avatar Aug 15 '22 12:08 pi0