0

Node version is 12.18 npm 6.14

npm install work fine, but while running npm run build I got error Cannot find module 'node:fs'

Require stack:

  • /var/www/frontend/node_modules/rc9/dist/index.cjs
  • /var/www/frontend/node_modules/@nuxt/config/dist/config.js
  • /var/www/frontend/node_modules/@nuxt/cli/dist/cli-index.js
  • /var/www/frontend/node_modules/@nuxt/cli/dist/cli.js
  • /var/www/frontend/node_modules/nuxt/bin/nuxt.js

Can anyone help, please?

I have already tried reinstalling modules with npm cache clean --force

Also, I can't upgrade node version (cause other dependencies crashes), but the idea is that all command work perfect on my local machine (with same node and npm versions). I'm facing this problem only on the remote server.

Bipa
  • 271
  • 1
  • 3
  • 10
  • `node:fs` isn't _expected_ to be in the modules directory, it's a core API: https://nodejs.org/api/fs.html. But the `node:`-prefixed imports (see https://nodejs.org/api/esm.html#node-imports) aren't available before 12.20.0 and 14.13.1. – jonrsharpe Feb 24 '23 at 11:39
  • okay, I read that `node:` imports aren't available for this version, that's why I mentioned, that I can't upgrade it, but why than nuxt is trying to import fs this way? I'm using `nuxt 2.15.3` and didn't find any doc with nuxt -> node versions compatibility – Bipa Feb 24 '23 at 11:42
  • Presumably because those versions were released in late 2020 (see https://nodejs.org/en/download/releases/) and Nuxt 2.15 came early the following year. If the error is coming from code you don't own and you cannot upgrade to at least the runtimes above (note v12 is out of support entirely), you'd have to ask the maintainers. – jonrsharpe Feb 24 '23 at 11:52

0 Answers0