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

npm install -g [email protected] with verbose loglevel crashes #3207

Closed
gfyoung opened this issue Jan 30, 2021 · 15 comments
Closed

npm install -g [email protected] with verbose loglevel crashes #3207

gfyoung opened this issue Jan 30, 2021 · 15 comments

Comments

@gfyoung
Copy link

gfyoung commented Jan 30, 2021

  • UPDATE: Issue persists with v15.11.0 and 7.6.3

  • UPDATE 2: Issue resolved with v16.3.0 and 7.18.1

Environment

  • Platform: Ubuntu 20.04.2 LTS
  • Docker Version: 20.10.2, build 2291f61
  • Node.js Version: 15.7.0
  • Image Tag: 15.7.0

Expected Behavior

npm install -g [email protected] should work.

Current Behavior

Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM node:15.7.0
 ---> ea27efc47a35
Step 2/3 : RUN npm set loglevel verbose
 ---> Running in 837598e30b06
npm notice 
npm notice New minor version of npm available! 7.4.3 -> 7.5.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.5.0>
npm notice Run `npm install -g [email protected]` to update!
npm notice 
Removing intermediate container 837598e30b06
 ---> 7630a48cb540
Step 3/3 : RUN npm install -g [email protected]
 ---> Running in df02af93a06c
npm verb cli [
npm verb cli   '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'install',
npm verb cli   '-g',
npm verb cli   '[email protected]'
npm verb cli ]
npm info using [email protected]
npm info using [email protected]
npm timing config:load:defaults Completed in 2ms
npm timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
npm timing config:load:builtin Completed in 1ms
npm timing config:load:cli Completed in 3ms
npm timing config:load:env Completed in 0ms
npm timing config:load:file:/.npmrc Completed in 1ms
npm timing config:load:project Completed in 1ms
npm timing config:load:file:/root/.npmrc Completed in 1ms
npm timing config:load:user Completed in 1ms
npm timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 0ms
npm timing config:load:cafile Completed in 1ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:setUserAgent Completed in 1ms
npm timing config:load:setEnvs Completed in 1ms
npm timing config:load Completed in 11ms
npm verb npm-session 0fd67c560e6d49d6
npm timing npm:load Completed in 25ms
npm timing arborist:ctor Completed in 1ms
npm timing idealTree:init Completed in 9ms
npm timing idealTree:userRequests Completed in 6ms
npm http fetch GET 200 https://registry.npmjs.org/npm 26ms (from cache)
npm timing idealTree:#root Completed in 61ms
npm timing idealTree:node_modules/npm Completed in 1ms
npm timing idealTree:buildDeps Completed in 63ms
npm timing idealTree:fixDepFlags Completed in 1ms
npm timing idealTree Completed in 83ms
npm timing reify:loadTrees Completed in 365ms
npm timing reify:diffTrees Completed in 7ms
npm timing reify:retireShallow Completed in 7ms
npm timing reify:createSparse Completed in 1ms
npm timing reify:rollback:createSparse Completed in 1ms
npm timing reify:rollback:retireShallow Completed in 1ms
npm timing command:install Completed in 597ms
npm verb stack Error: Cannot find module 'agentkeepalive'
npm verb stack Require stack:
npm verb stack - /usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
npm verb stack - /usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
npm verb stack - /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
npm verb stack - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/remote.js
npm verb stack - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/git.js
npm verb stack - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
npm verb stack - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/index.js
npm verb stack - /usr/local/lib/node_modules/npm/lib/utils/update-notifier.js
npm verb stack - /usr/local/lib/node_modules/npm/lib/cli.js
npm verb stack - /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm verb stack     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
npm verb stack     at Function.Module._load (node:internal/modules/cjs/loader:769:27)
npm verb stack     at Module.require (node:internal/modules/cjs/loader:997:19)
npm verb stack     at require (node:internal/modules/cjs/helpers:92:18)
npm verb stack     at getAgent (/usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js:70:17)
npm verb stack     at remoteFetch (/usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/index.js:267:17)
npm verb stack     at /usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/index.js:139:14
npm verb cwd /
npm verb Linux 5.4.0-1037-oracle
npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "[email protected]"
npm verb node v15.7.0
npm verb npm  v7.4.3
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/remote.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/git.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/index.js
npm ERR! - /usr/local/lib/node_modules/npm/lib/utils/update-notifier.js
npm ERR! - /usr/local/lib/node_modules/npm/lib/cli.js
npm ERR! - /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm verb exit 1
npm timing npm Completed in 920ms

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-01-30T00_01_48_107Z-debug.log
The command '/bin/sh -c npm install -g [email protected]' returned a non-zero code: 1

Possible Solution

N/A

Steps to Reproduce

FROM node:15.7.0

RUN npm set loglevel verbose
RUN npm install -g [email protected]

Create this Dockerfile in an empty folder. Run sudo docker build -t test:latest .

Filing bug here because this is the first time I have seen this issue in this environment.

I also can't seem to replicate running this locally (on my host machine).

@nschonni nschonni transferred this issue from nodejs/docker-node Jan 30, 2021
@ChamNouki
Copy link

got this error on my local computer (osx) trying to update from 7.0.14 to 7.6.1

@gfyoung gfyoung changed the title npm install -g [email protected] with verbose loglevel crashes npm install -g [email protected] with verbose loglevel crashes Mar 5, 2021
@sam-k
Copy link

sam-k commented Mar 15, 2021

Same error for macOS 11.1, trying to update from 7.6.0 to 7.6.3.

@gfyoung
Copy link
Author

gfyoung commented Mar 15, 2021

@sam-k @ChamNouki: If you're getting this error locally, it could be something with the local environment.

When I encountered that in the past, I generally just installed the missing dependency and then upgraded just fine e.g.

npm install -g agentkeepalive
npm install -g npm@latest

The issue here is that these builds (via Docker) should "just work" and should not be prone to those problems.

@jeremydyoung
Copy link

jeremydyoung commented Mar 17, 2021

I'm on WSL2 Ubuntu 20.04 LTS

Significantly, after installing node 15.11.0 with nvm, it installed npm v7.6.0, and the first use of npm showed:

npm notice
npm notice New patch version of npm available! 7.6.0 -> 7.6.3
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.6.3
npm notice Run npm install -g [email protected] to update!
npm notice

Running that command failed with:

npm  install -g [email protected]
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:

Eventually, running npm install -g npm without the version specified, worked just fine.

After upgrading without specifying a version, I can now specify a version and it works.

Further information is that nvm is not the only way that node / npm were installed on the system. apt-get installed versions exist on the system too, possibly causing conflicts?

@HawaiiRyan
Copy link

On a non-M1 Macbook Pro, it fails as well. Tried;
npm install -g npm
npm install -g npm@latest
npm install -g [email protected]

npm install -g npm npm ERR! code MODULE_NOT_FOUND npm ERR! Cannot find module 'agentkeepalive' npm ERR! Require stack: npm ERR! - /usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js npm ERR! - /usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/index.js npm ERR! - /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js npm ERR! - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/remote.js npm ERR! - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/git.js npm ERR! - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js npm ERR! - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/index.js npm ERR! - /usr/local/lib/node_modules/npm/lib/utils/update-notifier.js npm ERR! - /usr/local/lib/node_modules/npm/lib/cli.js npm ERR! - /usr/local/lib/node_modules/npm/bin/npm-cli.js

@aravindvnair99
Copy link

Node.js 15.13.0 here with npm 7.8.0

Failing in my CI environment when trying to upgrade to 7.9.0:

Step 11/14 : RUN npm -g config set user root
   ---> Running in f28f36afe680
  npm notice 
  npm notice New minor version of npm available! 7.8.0 -> 7.9.0
  npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.9.0>
  npm notice Run `npm install -g [email protected]` to update!
  npm notice 
  Removing intermediate container f28f36afe680
   ---> d5ec03d8a834
  Step 12/14 : RUN npm i -g npm@latest
   ---> Running in 30964ef6d112
  npm ERR! code MODULE_NOT_FOUND
  npm ERR! Cannot find module 'agentkeepalive'
  npm ERR! Require stack:
  npm ERR! - /usr/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
  npm ERR! - /usr/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
  npm ERR! - /usr/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
  npm ERR! - /usr/lib/node_modules/npm/node_modules/pacote/lib/remote.js
  npm ERR! - /usr/lib/node_modules/npm/node_modules/pacote/lib/git.js
  npm ERR! - /usr/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
  npm ERR! - /usr/lib/node_modules/npm/node_modules/pacote/lib/index.js
  npm ERR! - /usr/lib/node_modules/npm/lib/utils/update-notifier.js
  npm ERR! - /usr/lib/node_modules/npm/lib/cli.js
  npm ERR! - /usr/lib/node_modules/npm/bin/npm-cli.js
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /root/.npm/_logs/2021-04-08T18_15_42_999Z-debug.log
  The command '/bin/sh -c npm i -g npm@latest' returned a non-zero code: 1

Cross-posted from npm/cli#2818

@LiamFry
Copy link

LiamFry commented Apr 12, 2021

Exact same thing here under Debian.
I fixed the issue with npm install -g agentkeepalive --save then npm install -g [email protected]
However ... and this confuses me greatly ...
Before the update/installation of agentkeepalive and npm a find(1) revealed this:
/usr/local/nodejs/node-v15.14.0-linux-x64/lib/node_modules/npm/bin/npm
/usr/local/nodejs/node-v15.14.0-linux-x64/lib/node_modules/npm/node_modules/agentkeepalive

But now, after the updates, I have two (2) items for each ...
/usr/local/nodejs/node-v15.14.0-linux-x64/lib/node_modules/npm
/usr/local/nodejs/node-v15.14.0-linux-x64/lib/node_modules/npm/bin/npm
and
/usr/local/nodejs/node-v15.14.0-linux-x64/lib/node_modules/npm/node_modules/agentkeepalive
/usr/local/nodejs/node-v15.14.0-linux-x64/lib/node_modules/agentkeepalive

For each - nmp and agentkeepalive - I have an older version in one location which was from the original installation and the newer, updated version from the just-performed installs.

Why would the original put npm in .../lib/node_modules/npm/bin/nmp but install the update into .../lib/node_modules/npm ?

@redevill
Copy link

I'm on WSL2 Ubuntu 20.04 LTS

Significantly, after installing node 15.11.0 with nvm, it installed npm v7.6.0, and the first use of npm showed:

npm notice
npm notice New patch version of npm available! 7.6.0 -> 7.6.3
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.6.3
npm notice Run npm install -g [email protected] to update!
npm notice

Running that command failed with:

npm  install -g [email protected]
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:

Eventually, running npm install -g npm without the version specified, worked just fine.

I'm on an OSX 10.15.6 with Node 12.16.1
Same experience as above. Using the specific version number as stated in the install instructions fails (today as of this post) going from V7.7.6 - V7.9.0 with the same missing dependency error (agentkeepalive). No verbose switch needed to create the error.

However - npm install -g npm did work without error - also as per @jeremydyoung above.
Thanks

@cpcallen
Copy link

I was having the same issue with npm 7.6.3 -> 7.10.0 on node 12.22.1 on MacOS 10.15.7 (on Intel). npm i -g npm had been repeatedly failing, but it suddenly succeeded after running node --version and npm --version:

$ npm install -g npm
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:
npm ERR! - /usr/local/brew/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
npm ERR! - /usr/local/brew/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
npm ERR! - /usr/local/brew/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
npm ERR! - /usr/local/brew/lib/node_modules/npm/node_modules/pacote/lib/remote.js
npm ERR! - /usr/local/brew/lib/node_modules/npm/node_modules/pacote/lib/git.js
npm ERR! - /usr/local/brew/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
npm ERR! - /usr/local/brew/lib/node_modules/npm/node_modules/pacote/lib/index.js
npm ERR! - /usr/local/brew/lib/node_modules/npm/lib/utils/update-notifier.js
npm ERR! - /usr/local/brew/lib/node_modules/npm/lib/cli.js
npm ERR! - /usr/local/brew/lib/node_modules/npm/bin/npm-cli.js

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/cpcallen/.npm/_logs/2021-04-19T09_52_44_576Z-debug.log
$ node --version
v12.22.1
$ npm --version
7.6.3
$ npm install -g npm

removed 1 package, changed 14 packages, and audited 253 packages in 2s

11 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
$ npm --version
7.10.0

Here's the mentioned debug log: 2021-04-19T09_52_44_576Z-debug.log

@redevill
Copy link

redevill commented Apr 19, 2021

FYI - There is also an issue with Package.json variables, and the ability to override npm_package_ prefix variables. V7~ breaks the V6 behavior.

See issue: [BUG] Package.json Vars $npm_config_{key} $npm_package_ are not in scope of the package.json scripts
npm/cli#3077

@brkline
Copy link

brkline commented Apr 30, 2021

For those running WSL2: I had the same issue and tried npm install -g npm without success. When I ran the original command npm install -g [email protected], I was in my Windows mount point, /mnt/c/Users/xxxxxx. I then changed to my Linux home directory by doing cd ~/, ran npm install -g [email protected] again, and it upgraded successfully. I'm not saying that's everyone's environment setup and I'm not sure if it's coincidence or not but just thought I would offer it.

@MattWilcox
Copy link

I was having the same issue with npm 7.6.3 -> 7.10.0 on node 12.22.1 on MacOS 10.15.7 (on Intel). npm i -g npm had been repeatedly failing, but it suddenly succeeded after running node --version and npm --version:

Can confirm, just running node --version && npm --version then sudo npm i -g npm "just worked". OSX 11.2.3; Intel.

@benrbray
Copy link

benrbray commented May 5, 2021

I received this error on Ubuntu 20.04 (pure Ubuntu, not WSL). I got a notification to update to a new minor version:

npm notice 
npm notice New minor version of npm available! 7.6.0 -> 7.11.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.11.2
npm notice Run npm install -g [email protected] to update!
npm notice

When I ran the command, I received the same agentkeepalive error.

(click to expand) npm ERR! code MODULE_NOT_FOUND

$ sudo npm install -g [email protected]
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/remote.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/git.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/pacote/lib/index.js
npm ERR! - /usr/local/lib/node_modules/npm/lib/utils/update-notifier.js
npm ERR! - /usr/local/lib/node_modules/npm/lib/cli.js
npm ERR! - /usr/local/lib/node_modules/npm/bin/npm-cli.js

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-05-05T06_11_42_903Z-debug.log

Running npm --version && node --version fixed the problem.

@Cholisky
Copy link

Just had the exact same issue with 7.13.0. I installed the missing module with npm and then npm updated just fine.
npm install -g agentkeepalive
npm install -g npm@latest

@gfyoung
Copy link
Author

gfyoung commented Jun 20, 2021

With 15.x having reached EOL, I can confirm that the combo of v16.3.0 and 7.18.1 works as expected. Closing.

@gfyoung gfyoung closed this as completed Jun 20, 2021
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