Running npm update -g inside node:latest completes but causes npm to break on all subsequent calls.
Similar errors appear in node:alpine and node:boron.
The test command does work with node:argon
docker pull node:latest && docker run --rm node:latest sh -c "npm update -g && npm -v"I expected to see the new npm version number printed
I get the error: Cannot find module 'npmlog'.
If I run npm install -g npmlog before the update command, the error becomes Cannot find module 'update-notifier'. If I install that, the error becomes Cannot find module 'graceful-fs' and so on, I didn't find the end, even after pre-installing config-chain, inherits, and nopt.
% docker pull node:latest && docker run --rm node:latest sh -c "npm update -g && npm -v"
latest: Pulling from library/node
Digest: sha256:a8918e06476bef51ab83991aea7c199bb50bfb131668c9739e6aa7984da1c1f6
Status: Image is up to date for node:latest
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info attempt registry request try #1 at 02:29:48
[...]
chunk deleted for bug report
[...]
npm info lifecycle [email protected]~postinstall: [email protected]
+ [email protected]
added 73 packages, removed 24 packages and updated 44 packages in 23.12s
npm info ok
module.js:529
throw err;
^
Error: Cannot find module 'npmlog'
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._load (module.js:476:23)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:22:13
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
The issue might be with the -g. See https://github.com/nodejs/docker-node/pull/540/files
npm@5 is unable to update itself in a docker container. Doing yarn global add npm usually works.
https://github.com/nodejs/docker-node/issues/520#issuecomment-329051521
https://github.com/nodejs/docker-node/issues/449#issuecomment-313298955
https://github.com/nodejs/docker-node/issues/450#issuecomment-313478048
Closing as this is not actionable on our side, and a workaround has been posted
Most helpful comment
npm@5 is unable to update itself in a docker container. Doing
yarn global add npmusually works.https://github.com/nodejs/docker-node/issues/520#issuecomment-329051521
https://github.com/nodejs/docker-node/issues/449#issuecomment-313298955
https://github.com/nodejs/docker-node/issues/450#issuecomment-313478048