Friday, 2 June 2017

Cannot find module 'fs.realpath' after NPM v5.0.1 upgrade

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 find, 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 back@0.0.1~start: Failed to exec start script
14 verbose stack Error: back@0.0.1 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.



via WillyC

No comments:

Post a Comment