nuxt-windicss icon indicating copy to clipboard operation
nuxt-windicss copied to clipboard

NPM - Cannot find module '@nuxt/kit'

Open tonyketcham opened this issue 3 years ago • 16 comments

Describe the bug [email protected] is not compatible with Nuxt 2 following installation documentation

To Reproduce

  1. Clone minimum example repo demonstrating problem: https://github.com/tonyketcham/nuxt-v2-windicss-v2.0.3-bug
  2. Run npm i, npm run dev
  3. See error

Expected behavior Idyllic experience transcending the human form aka it works

Consoleshots

nuxt-windicss-2.0.3-bug on 🌱 mast [🤷‍] via 🤖 v14.18.0 took 13s
➜ npm run dev

> [email protected] dev /Users/tony/GNL/nuxt-windicss-2.0.3-bug
> nuxt


 WARN  Module nuxt-windicss not found. Please ensure nuxt-windicss is in devDependencies and installed. HINT: During build step, for npm/yarn, NODE_ENV=production or --production should NOT be used.


 FATAL  Cannot find module '@nuxt/kit'                                                     10:57:38
Require stack:
- /Users/tony/GNL/nuxt-windicss-2.0.3-bug/node_modules/nuxt-windicss/dist/index.cjs

  Require stack:
  - node_modules/nuxt-windicss/dist/index.cjs
  at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
  at Function.resolve (internal/modules/cjs/helpers.js:99:19)
  at p (node_modules/jiti/dist/jiti.js:1:52925)
  at g (node_modules/jiti/dist/jiti.js:1:54200)
  at node_modules/nuxt-windicss/dist/index.cjs:8:13
  at Resolver.g [as _require] (node_modules/jiti/dist/jiti.js:1:55111)
  at Resolver.requireModule (node_modules/@nuxt/core/dist/core.js:381:29)
  at ModuleContainer.addModule (node_modules/@nuxt/core/dist/core.js:182:38)
  at node_modules/@nuxt/utils/dist/utils.js:639:43
  at async ModuleContainer.ready (node_modules/@nuxt/core/dist/core.js:51:7)


   ╭───────────────────────────────────────────────────────────────────────────────────────╮
   │                                                                                       │
   │   ✖ Nuxt Fatal Error                                                                  │
   │                                                                                       │
   │   Error: Cannot find module '@nuxt/kit'                                               │
   │   Require stack:                                                                      │
   │   -                                                                                   │
   │   /Users/tony/GNL/nuxt-windicss-2.0.3-bug/node_modules/nuxt-windicss/dist/index.cjs   │
   │                                                                                       │
   ╰───────────────────────────────────────────────────────────────────────────────────────╯

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `nuxt`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Additional context Add any other context about the problem here.

➜ npm -v
6.14.15
➜ node -v
v14.18.0

MacOS v10.15.7

tonyketcham avatar Oct 19 '21 16:10 tonyketcham

Hey @tonyketcham

Thanks for the detailed issue. Seems like there is something going wrong with the npm aliasing.

I'll see if I can find a workaround soon, for the time being using yarn or pnpm will fix it.

harlan-zw avatar Oct 20 '21 12:10 harlan-zw

Looks to be fixed in 2.0.4, thanks again :)

harlan-zw avatar Oct 21 '21 01:10 harlan-zw

Hi @harlan-zw. I have made a testing package:

https://unpkg.com/browse/@pi0/[email protected]/package.json

@pi0/kit-test can be installed just fine with npm 6.14.15

(investigating)

pi0 avatar Oct 21 '21 13:10 pi0

Hi @harlan-zw. I have made a testing package:

https://unpkg.com/browse/@pi0/[email protected]/package.json

@pi0/kit-test can be installed just fine with npm 6.14.15

So I'm afraid something else went wrong.

Yeh something weird going on for sure 🤔 thanks for the test package, 2.0.4 just uses the edge version directly but I'll look to get the alias working at some point soon

harlan-zw avatar Oct 21 '21 13:10 harlan-zw

Same problem on fresh installation of nuxt. I used latest "nuxt-windicss": "^2.0.13".

gnidustotalus avatar Dec 07 '21 07:12 gnidustotalus

I got the same problem with the lastest [email protected].

ShermanTsang avatar Dec 26 '21 09:12 ShermanTsang

Oh no, I have the same issue, but this happens when I deploy to Netlify and nuxt generate runs

package.json

"dependencies": {
    "@nuxtjs/axios": "^5.13.6",
    "@nuxtjs/google-analytics": "^2.4.0",
    "nuxt": "^2.13.2"
  },
  "devDependencies": {
    "@babel/core": "7.13.15",
    "@babel/preset-env": "^7.14.8",
    "@nuxtjs/color-mode": "^2.1.1",
    "@nuxtjs/google-fonts": "^1.3.0",
    "@nuxtjs/pwa": "^3.3.5",
    "core-js": "^3.20.1",
    "nuxt-vite": "^0.3.5",
    "nuxt-windicss": "^2.2.2",
    "vite-plugin-windicss": "^1.6.1",
    "windicss": "^3.4.2"
  }

Error Captura de Pantalla 2021-12-31 a la(s) 18 07 23

cesswhite avatar Jan 01 '22 00:01 cesswhite

I got the same problem with the lastest [email protected]. First of all, I solved it by using yarn instead of npm.

0oooooooo0 avatar Feb 07 '22 05:02 0oooooooo0

@hanjonglee I switched to yarn to test and when I run yarn build on local it generates the .nuxt folder without problems, however when deployed to netlify, I got this error:

Error to deploy

Captura de Pantalla 2022-02-08 a la(s) 15 30 47

cesswhite avatar Feb 08 '22 21:02 cesswhite

Seems like maybe a node 12.x issue with netlify? Can you try and set the node version to at least 14.x https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript

harlan-zw avatar Feb 08 '22 23:02 harlan-zw

Seems like maybe a node 12.x issue with netlify? Can you try and set the node version to at least 14.x https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript

Thank you!

cesswhite avatar Feb 09 '22 02:02 cesswhite

I solved it by using yarn instead of npm.

Interesting that I "solved" it the other way around :) by using npm instead of yarn!

dudintv avatar Aug 26 '23 15:08 dudintv

me too, I use yarn 3.5.0, maybe because of that

baguilarq avatar Aug 31 '23 18:08 baguilarq

Same for me, I use yarn 3.5.0 try to init a nuxt project and got this:

❯ yarn install
➤ YN0000: ┌ Resolution step
➤ YN0002: │ nuxt-app@workspace:. doesn't provide vite (pc88f8), requested by @nuxt/devtools
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ nuxt-app@workspace:. must be built because it never has been before or the last one failed
➤ YN0009: │ nuxt-app@workspace:. couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/_w/08nkcdr543vb0sgwrmz9k00r0000gn/T/xfs-b2c9c1bd/build.log)
➤ YN0000: └ Completed in 0s 573ms
➤ YN0000: Failed with errors in 0s 750ms
❯ cat /private/var/folders/_w/08nkcdr543vb0sgwrmz9k00r0000gn/T/xfs-b2c9c1bd/build.log
# This file contains the result of Yarn building a package (nuxt-app@workspace:.)
# Script name: postinstall


 ERROR  Error: Cannot find module @nuxt/kit imported from file:///Users/alex/Projects/web/my-music, file:///Users/alex/Projects/web/, file:///Users/alex/Projects/web/my-music/_index.js, file:///Users/alex/Projects/web/node_modules

  at resolvePath (.yarn/cache/nuxi-npm-3.9.0-381be7ffe6-12e36bd4ec.zip/node_modules/nuxi/dist/shared/nuxi.4456790d.mjs:7954:10)
  at importModule (.yarn/cache/nuxi-npm-3.9.0-381be7ffe6-12e36bd4ec.zip/node_modules/nuxi/dist/shared/nuxi.c0869f34.mjs:11:30)
  at loadKit (.yarn/cache/nuxi-npm-3.9.0-381be7ffe6-12e36bd4ec.zip/node_modules/nuxi/dist/shared/nuxi.bf5ca6d6.mjs:9043:21)
  at async Object.run (.yarn/cache/nuxi-npm-3.9.0-381be7ffe6-12e36bd4ec.zip/node_modules/nuxi/dist/chunks/prepare.mjs:57:9)
  at async runCommand$1 (.yarn/cache/nuxi-npm-3.9.0-381be7ffe6-12e36bd4ec.zip/node_modules/nuxi/dist/shared/nuxi.9d864d83.mjs:1647:7)
  at async runCommand$1 (.yarn/cache/nuxi-npm-3.9.0-381be7ffe6-12e36bd4ec.zip/node_modules/nuxi/dist/shared/nuxi.9d864d83.mjs:1638:11)
  at async runMain$1 (.yarn/cache/nuxi-npm-3.9.0-381be7ffe6-12e36bd4ec.zip/node_modules/nuxi/dist/shared/nuxi.9d864d83.mjs:1770:7)



 ERROR  Error: Cannot find module @nuxt/kit imported from file:///Users/alex/Projects/web/my-music, file:///Users/alex/Projects/web/, file:///Users/alex/Projects/web/my-music/_index.js, file:///Users/alex/Projects/web/node_modules

alexandrucaraus avatar Oct 10 '23 17:10 alexandrucaraus

when using Yarn i managed to solve this by adding

nodeLinker: node-modules

to my .yarnrc.yml

diogen737 avatar Oct 27 '23 15:10 diogen737

@diogen737 nice! I gave up with yarn and used bun.

alexandrucaraus avatar Oct 27 '23 15:10 alexandrucaraus