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

Fatal error with v1.16.1: Cannot find module 'node:module' #109

Closed
dockleryxk opened this issue Jan 3, 2023 · 12 comments
Closed

Fatal error with v1.16.1: Cannot find module 'node:module' #109

dockleryxk opened this issue Jan 3, 2023 · 12 comments

Comments

@dockleryxk
Copy link

dockleryxk commented Jan 3, 2023

Edit: Workarounds

If possible, update to Node 16 or higher (thanks @fanwei1991).

If you're using yarn, you can add this to your package.json (thanks @smyth64):

"resolutions": { 
   "jiti": "1.16.0" 
}

If you're using a new enough version of NPM, you can add this to your package.json (but be aware of the caveats):

"overrides": { 
   "jiti": "1.16.0" 
}

Environment

Node 12.6.0 (also happens on Node 14.17)

Reproduction

Installing nuxt on a fresh docker container

Describe the bug

This is pretty much identical to #48

Logs

FATAL  Cannot find module 'node:module'
  Require stack:
  - xxx/my-project/node_modules/jiti/dist/jiti.js
  - xxx/my-project/node_modules/jiti/lib/index.js
  - xxx/my-project/node_modules/@nuxt/utils/dist/utils.js
  - xxx/my-project/node_modules/@nuxt/cli/dist/cli-index.js
  - xxx/my-project/node_modules/@nuxt/cli/dist/cli.js
  - xxx/my-project/node_modules/nuxt/bin/nuxt.js
@dockleryxk dockleryxk changed the title Fatal error with v1.16.1 Fatal error with v1.16.1: Cannot find module 'node:module' Jan 3, 2023
@tidusvn05
Copy link

i same for jiti@1.16.1 on docker gitlab

@sanjeet2009
Copy link

sanjeet2009 commented Jan 3, 2023

Same for me:

Tried "overrides": {"jiti": "1.14.0"}, But it has not worked.

`> nuxt build --modern=server
FATAL Cannot find module 'node:module'
Require stack:

  • /app/node_modules/jiti/dist/jiti.js
  • /app/node_modules/jiti/lib/index.js
  • /app/node_modules/@nuxt/utils/dist/utils.js
  • /app/node_modules/@nuxt/cli/dist/cli-index.js
  • /app/node_modules/@nuxt/cli/dist/cli.js
  • /app/node_modules/nuxt/bin/nuxt.js
    Require stack:
    • node_modules/jiti/dist/jiti.js
    • node_modules/jiti/lib/index.js
    • node_modules/@nuxt/utils/dist/utils.js
    • node_modules/@nuxt/cli/dist/cli-index.js
    • node_modules/@nuxt/cli/dist/cli.js
    • node_modules/nuxt/bin/nuxt.js
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
      at Function.Module._load (internal/modules/cjs/loader.js:745:27)
      at Module.require (internal/modules/cjs/loader.js:961:19)
      at require (internal/modules/cjs/helpers.js:92:18)
      at node_modules/jiti/dist/jiti.js:1:215165
      at node_modules/jiti/dist/jiti.js:1:249320
      at Object. (node_modules/jiti/dist/jiti.js:1:249367)
      at Module._compile (internal/modules/cjs/loader.js:1072:14)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
      at Module.load (internal/modules/cjs/loader.js:937:32)
      ╭─────────────────────────────────────────────────────╮`

@vietanh74
Copy link

vietanh74 commented Jan 4, 2023

@dockleryxk i think your NodeJS version is <= 12, upgrade node or fix "jiti": "1.16.0" to resolve it.
node: is new syntax in nodejs.

@remirobichet
Copy link

remirobichet commented Jan 4, 2023

As mentioned @dockleryxk this error is similar to #48
@pi0 fixed it by removing mlly package.
Isn't it still related to mlly ? Package have been updated to v1.0.0 in jiti 1.16.1

"mlly": "^1.0.0",

Edit:
Some changes from mlly related to node:module can produce the error:
unjs/mlly@v0.5.14...v1.0.0
https://github.com/unjs/mlly/blob/6905f5940406d8745e5d9f67506ede30715b2255/src/_utils.ts#L1
https://github.com/unjs/mlly/blob/6905f5940406d8745e5d9f67506ede30715b2255/src/cjs.ts#L2

@smyth64
Copy link

smyth64 commented Jan 4, 2023

I also have the same problem since today, cannot deploy my app anymore :o

@smyth64
Copy link

smyth64 commented Jan 4, 2023

I found a solution 😍 ⭐️

The problem is the jiti update.

I fixed it by using the previous jiti version on nuxt utils :)

"resolutions": { "nuxt/@nuxt/utils/jiti": "1.16.0" },

@dockleryxk
Copy link
Author

dockleryxk commented Jan 4, 2023

@vietanh74 I can confirm the same thing happens on Node 14.17.

Adding the resolutions works only for yarn, and there is an overrides field for newer versions on NPM (albeit with caveats), but that isn't a great solution in the long term.

In the short term, we're using yarn resolutions while we wait for a fix.

@pi0 thank you for your work on this package!

@fanwei1991
Copy link

I also encountered this problem. node 14.17.0 was unavailable. After upgrading node to 16, this problem was removed

@daglenn1960
Copy link

Encountered this issue as well. Doing these did not work:

  • reverting to jiti 1.14.0
  • updating to node 16.16.0

Fix was both:

  • adding override (as above) [jiti 1.16.0]
  • updating to node 16.16.0

@freezyh
Copy link

freezyh commented Jan 10, 2023

"overrides": { 
   "jiti": "1.16.0" 
}

Tried "overrides": {"jiti": "1.14.0"}, But it has not worked.

@xukingnie
Copy link

node 14.16.0 also have the same problem

@pi0 pi0 closed this as completed in 1fa8d5d Jan 10, 2023
@pi0
Copy link
Member

pi0 commented Jan 10, 2023

jiti@1.16.2 should work again on older Node.js versions without node: protocol support.

If still having issues after updating and recreating lockfile, please ping to reopen.

If possible, please try upgrading Node.js to the latest 16.x or 18.x LTS.

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