I recently updated npm to v5.0.1 (from the last version of 4), and it has been generally catastrophic.
Anyway, I'm stuck at this point. Any node.js application I try to run completes an 'npm install' fine, but when started outputs:
module.js:471
throw err;
^
Error: Cannot find module 'fs.realpath'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/user/back/node_modules/glob/glob.js:44:10)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
Note that this same application will run fine on macOs, but on Ubuntu 16.04.2 LTS it gives the above error.
I've removed the node_modules directory on both machines and re-run, macOs works fine, Ubuntu fails.
node -v: v6.10.3
...for both machines.
npm -v: 5.0.1
It also suggests I look at the log (/home/user/.npm/_logs/2017-06-02T23_19_59_859Z-debug.log), but it gives even less information. Here's the error reported there:
13 info lifecycle [email protected]~start: Failed to exec start script
14 verbose stack Error: [email protected] start: `tsc && npm run moveassets && NODE_ENV=production forever start -a -l back.log -e back-err.log ./build/www.js `
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:886:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
Note that until the fateful upgrading of NPM to v5.0.1, it worked fine on both machines.
UPDATE WITH PROBLEM ISOLATED:
It seems it isn't the OS version, but the fact that macOS was generating the package-lock.json file and Ubuntu was consuming it and basing its install from it. As noted below, if you remove the file and rm -r node_modules folder, you can install and it will all work fine (but you won't get the version locking benefits, obviously).
I think it is just a bug with the current version of NPM. Fair enough, it was a big change and will be a good feature when done.
If you
rm -rf node_modules
then do a
npm install
again, it works.
Note: I also removed the npm lock file.
Update :
(with taking comment in consideration)
rm -rf node_modules
rm package-lock.json
npm install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With