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

[BUG] "ERR! Cannot find module 'agentkeepalive'" trying to "npm install -g npm@7.6.0" #2818

Closed
codingthat opened this issue Mar 4, 2021 · 30 comments
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@codingthat
Copy link

As far as I know, this is not:

Current Behavior:

When I open a terminal, I get this message:

npm notice
npm notice New minor version of npm available! 7.5.3 -> 7.6.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.6.0
npm notice Run npm install -g npm@7.6.0 to update!
npm notice

When I run npm install -g npm@7.6.0 as it suggests, I get:

npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:
npm ERR! - /home/me/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
npm ERR! - /home/me/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
npm ERR! - /home/me/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
npm ERR! - /home/me/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/pacote/lib/remote.js
npm ERR! - /home/me/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/pacote/lib/git.js
npm ERR! - /home/me/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
npm ERR! - /home/me/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/pacote/lib/index.js
npm ERR! - /home/me/.nvm/versions/node/v12.16.1/lib/node_modules/npm/lib/utils/update-notifier.js
npm ERR! - /home/me/.nvm/versions/node/v12.16.1/lib/node_modules/npm/lib/cli.js
npm ERR! - /home/me/.nvm/versions/node/v12.16.1/lib/node_modules/npm/bin/npm-cli.js

npm ERR! A complete log of this run can be found in:
npm ERR! /home/me/.npm/_logs/2021-03-04T07_50_45_244Z-debug.log

Expected Behavior:

A successful upgrade to npm 7.6.0.

Steps To Reproduce:

  1. In Linux Mint 19.3 64-bit,
  2. With nvm installed and pointing to v12.16.1 as the default,
  3. Run npm install -g npm@7.6.0
  4. See the above error
@codingthat codingthat added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Mar 4, 2021
@codingthat
Copy link
Author

Interestingly, despite npm --version showing 7.5.3 (matching the terminal notice I was given), I discovered this in attempting to update Node.js itself using nvm just now:

$ nvm use 14.16.0
Now using node v14.16.0 (npm v6.14.11)

So...I ran nvm install-latest-npm and that worked. Now nvm reports npm 7.6.0, and so does npm --version. Hurray!

I guess then the notice should be changed for those of us running nvm?

(I'm also curious why the recommended method didn't work, because I'm pretty sure I've upgraded exactly the same way previously, without trouble.)

@ljharb
Copy link
Collaborator

ljharb commented Mar 4, 2021

Unfortunately npm v7.5.3 had some issues, and once you'd upgraded to it in your node v12.16.1, you may have had to uninstall and reinstall that node version to be able to get a newer version of npm. I don't think this has anything to do with nvm itself (except that you were able to switch to a different node version that avoided the problem)

@codingthat
Copy link
Author

Ah, OK...I didn't have to uninstall anything, I just used nvm to install the latest Node.js and then used nvm to install the latest npm. I'm not sure installing the latest Node.js even helped, necessarily, because as you can see above, the latest still had npm v6 attached to it.

@ljharb
Copy link
Collaborator

ljharb commented Mar 4, 2021

Only node 15 ships with npm 7 initially.

@paulvandenburg
Copy link

I'm not sure if this is the exact same issue, but I also have trouble upgrading my npm to the latest version (now 7.6.1) and I'm on Linux Mint 19.3 as well.
I'm not using nvm but using node 14.16.0.
I'm currently already on npm version 7.6.0, but attempting the upgrade (npm i -g npm) gives a similar error:

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

@PierrickGT
Copy link

I'm not sure if this is the exact same issue, but I also have trouble upgrading my npm to the latest version (now 7.6.1) and I'm on Linux Mint 19.3 as well.
I'm not using nvm but using node 14.16.0.
I'm currently already on npm version 7.6.0, but attempting the upgrade (npm i -g npm) gives a similar error:

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

Had the same problem on Mac OS when running npm install -g npm@7.6.1 it works perfectly by running npm install -g npm@latest
Hope it helps :)

@paulvandenburg
Copy link

Just retried the same npm i -g npm and it succeeded this time. Maybe there was some quirk in the npm repos that has been resolved in the mean time?

@codingthat
Copy link
Author

Interesting that the different formats give different results even though they target the same version in the end! Maybe that's the easiest way to fix the notification text so that it's universally applicable, then...

@xakraz
Copy link

xakraz commented Mar 25, 2021

Hi there 👋🏻

I am currently facing the same issue.

Env:

  • Docker image: node:15-alpine
  • Node: v15.12.0
  • Npm 7.6.3
FROM node:15-alpine

# == Runtime config
#
RUN printf '\e[1;32m%-6s\e[m\n' "RUN - Updating NodeJS environment" \
    && npm set progress=false \
    && npm update -g npm \
    && printf '\e[1;32m%-6s\e[m\n' "-> Print version" \
    && node --version \
    && npm --version
npm notice 
npm notice New minor version of npm available! 7.6.3 -> 7.7.4
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.7.4>
npm notice Run `npm install -g npm@7.7.4` to update!
npm notice 
npm notice 
npm notice New minor version of npm available! 7.6.3 -> 7.7.4
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.7.4>
npm notice Run `npm install -g npm@7.7.4` to update!
npm notice 
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-03-25T15_07_44_458Z-debug.log

@xakraz
Copy link

xakraz commented Mar 25, 2021

Interesting ...

When removing the line npm set progress=false it works every time 🤔

RUN - Updating NodeJS environment
-> Install latest 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 notice 
npm notice New minor version of npm available! 7.6.3 -> 7.7.4
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.7.4>
npm notice Run `npm install -g npm@7.7.4` to update!
npm notice 
-> Print version
Node: v15.12.0
Npm: 7.7.4

@mikeharder
Copy link

This appears to be a transient issue. Using these repro steps, sometimes the install succeeds, and sometimes it fails with Cannot find module 'agentkeepalive':

$ docker run -it --rm --entrypoint bash node:15

root@9a2b1d9bf8b5:/# npm install -g npm@7.7.5

@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 npm@7.9.0` 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

@JeffSpies
Copy link

Just to add a data point, if it helps:

Same error as OP for node v15.5.0 installed via nvm 0.35.3 on Ubuntu 18.04.5 LTS. Installed agentkeepalive manually to get npm updated.

@feross
Copy link

feross commented Apr 20, 2021

Installed node via brew install node and getting the same error upgrading from npm 7.9.0 to 7.9.10.

$ node -v
v15.14.0
$ npm -v
7.9.0
$ npm i -g npm@latest
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/pacote/lib/remote.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/pacote/lib/git.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/pacote/lib/index.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/lib/utils/update-notifier.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/lib/cli.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/bin/npm-cli.js

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/feross/.npm/_logs/2021-04-20T00_27_14_612Z-debug.log

I'm on an M1 Mac.

@dereuromark
Copy link

dereuromark commented Apr 20, 2021

Same here. Linux Mint 20

@evictor
Copy link

evictor commented Apr 20, 2021

Same on Big Sur 16" MBP 2019. I predict 3,000 "me too" comments coming soon. 🤔

Perhaps obviously, installing agentkeepalive will then allow you to upgrade your npm: npm i -g agentkeepalive

@hs749
Copy link

hs749 commented Apr 30, 2021

I got the same error (ERR! Cannot find module 'agentkeepalive') when trying to run the update for npm globally:
npm install -g npm@7.11.2
Then after I installed module 'agentkeepalive' globally, i.e. npm install -g agentkeepalive, ran the npm update again and it worked. Maybe a temporary workaround ?

@darcyclarke darcyclarke added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels May 7, 2021
@altertic
Copy link

Perhaps obviously, installing agentkeepalive will then allow you to upgrade your npm: npm i -g agentkeepalive

I got the same error (ERR! Cannot find module 'agentkeepalive') when trying to run the update for npm globally:
npm install -g npm@7.11.2
Then after I installed module 'agentkeepalive' globally, i.e. npm install -g agentkeepalive, ran the npm update again and it worked. Maybe a temporary workaround ?

Thanks @evictor (and @hs749 for confirming), it seems to be a solid workaround, worked like a charm for me :)

I had the same issue while trying to update npm from 7.11.2 to 7.13.0:
npm ERR! code MODULE_NOT_FOUND npm ERR! Cannot find module 'agentkeepalive'

I installed "agentkeepalive" (npm install -g agentkeepalive) and then I've been able to install 7.13.0 without any issue.

[Linux 64 / Pop!_OS 20.10 (Intel version)]

@stickyburn
Copy link

It makes sense for the update to work after a npm install -g agentkeepalive , but shouldn't this be included in the build if it's a needed dependency?

[Faced on Arch 5.12.4 Intel]

@ljharb
Copy link
Collaborator

ljharb commented May 18, 2021

@yashank09 i believe it's long since been fixed, but anyone stuck on older npm versions where this problem exists can't ever avoid having this problem.

@stickyburn
Copy link

@ljharb I see. I was setting up a new system so just installed nvm on arch. The older version was included by default which led me to this error. This should be resolved once nvm upgrades to the latest version out of box.

@ljharb
Copy link
Collaborator

ljharb commented May 19, 2021

@yashank09 it's got nothing to do with nvm. the version of node installed is determined by your .nvmrc file, your nvm default alias, or the version you pass to nvm install - it doesn't do anything specific by default.

@ArfyFR
Copy link

ArfyFR commented May 19, 2021

Also faced the

npm install -g npm@7.13.0
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:
npm ERR! - C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\agent.js
npm ERR! - C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\index.js
npm ERR! - C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-fetch\index.js
npm ERR! - C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\remote.js
npm ERR! - C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\git.js
npm ERR! - C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetcher.js
npm ERR! - C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\index.js
npm ERR! - C:\Program Files\nodejs\node_modules\npm\lib\utils\update-notifier.js
npm ERR! - C:\Program Files\nodejs\node_modules\npm\lib\cli.js
npm ERR! - C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js

on Windows 10 Pro

@anentropic
Copy link

anentropic commented May 25, 2021

same here

it worked on second attempt though

npm notice New minor version of npm available! 7.9.0 -> 7.14.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.14.0
npm notice Run npm install -g npm@7.14.0 to update!
npm notice

$ npm install -g npm@7.14.0
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:
npm ERR! - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
npm ERR! - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
npm ERR! - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
npm ERR! - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/pacote/lib/remote.js
npm ERR! - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/pacote/lib/git.js
npm ERR! - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
npm ERR! - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/pacote/lib/index.js
npm ERR! - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/lib/utils/update-notifier.js
npm ERR! - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/lib/cli.js
npm ERR! - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/bin/npm-cli.js

$ nvm current
v14.16.1

$ npm install -g npm@7.14.0

changed 14 packages, and audited 255 packages in 3s

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

found 0 vulnerabilities

$ npm --version
7.14.0

here is the log in case it gives any clues

0 verbose cli [
0 verbose cli   '/Users/anentropic/.nvm/versions/node/v14.16.1/bin/node',
0 verbose cli   '/Users/anentropic/.nvm/versions/node/v14.16.1/bin/npm',
0 verbose cli   'install',
0 verbose cli   '-g',
0 verbose cli   'npm@7.14.0'
0 verbose cli ]
1 info using npm@7.9.0
2 info using node@v14.16.1
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:/Users/anentropic/Documents/Dev/Work/MyJob/myproject/.npmrc Completed in 0ms
10 timing config:load:project Completed in 0ms
11 timing config:load:file:/Users/anentropic/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/Users/anentropic/.nvm/versions/node/v14.16.1/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 5ms
18 timing npm:load:configload Completed in 5ms
19 timing npm:load:setTitle Completed in 0ms
20 timing npm:load:setupLog Completed in 1ms
21 timing npm:load:cleanupLog Completed in 1ms
22 timing npm:load:configScope Completed in 0ms
23 timing npm:load:projectScope Completed in 0ms
24 timing npm:load Completed in 9ms
25 timing config:load:flatten Completed in 2ms
26 timing arborist:ctor Completed in 1ms
27 timing idealTree:init Completed in 8ms
28 timing idealTree:userRequests Completed in 3ms
29 silly idealTree buildDeps
30 silly fetch manifest npm@7.14.0
31 http fetch GET 200 https://registry.npmjs.org/npm 14ms (from cache)
32 silly placeDep ROOT npm@7.14.0 OK for:  want: 7.14.0
33 timing idealTree:#root Completed in 32ms
34 timing idealTree:node_modules/npm Completed in 0ms
35 timing idealTree:buildDeps Completed in 33ms
36 timing idealTree:fixDepFlags Completed in 0ms
37 timing idealTree Completed in 45ms
38 timing reify:loadTrees Completed in 174ms
39 timing reify:diffTrees Completed in 4ms
40 silly reify mark retired [
40 silly reify   '/Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm',
40 silly reify   '/Users/anentropic/.nvm/versions/node/v14.16.1/bin/npm',
40 silly reify   '/Users/anentropic/.nvm/versions/node/v14.16.1/bin/npx'
40 silly reify ]
41 silly reify moves {
41 silly reify   '/Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm': '/Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/.npm-Xn9Q2q5v',
41 silly reify   '/Users/anentropic/.nvm/versions/node/v14.16.1/bin/npm': '/Users/anentropic/.nvm/versions/node/v14.16.1/bin/.npm-k00JPIzT',
41 silly reify   '/Users/anentropic/.nvm/versions/node/v14.16.1/bin/npx': '/Users/anentropic/.nvm/versions/node/v14.16.1/bin/.npx-coABEeTR'
41 silly reify }
42 timing reify:retireShallow Completed in 4ms
43 timing reify:createSparse Completed in 0ms
44 silly tarball no local data for npm@https://registry.npmjs.org/npm/-/npm-7.14.0.tgz. Extracting by manifest.
45 timing reify:rollback:createSparse Completed in 0ms
46 timing reify:rollback:retireShallow Completed in 1ms
47 timing command:install Completed in 195ms
48 verbose stack Error: Cannot find module 'agentkeepalive'
48 verbose stack Require stack:
48 verbose stack - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
48 verbose stack - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
48 verbose stack - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
48 verbose stack - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/pacote/lib/remote.js
48 verbose stack - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/pacote/lib/git.js
48 verbose stack - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
48 verbose stack - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/pacote/lib/index.js
48 verbose stack - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/lib/utils/update-notifier.js
48 verbose stack - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/lib/cli.js
48 verbose stack - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/bin/npm-cli.js
48 verbose stack     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
48 verbose stack     at Function.Module._load (internal/modules/cjs/loader.js:725:27)
48 verbose stack     at Module.require (internal/modules/cjs/loader.js:952:19)
48 verbose stack     at require (internal/modules/cjs/helpers.js:88:18)
48 verbose stack     at getAgent (/Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js:70:17)
48 verbose stack     at remoteFetch (/Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/make-fetch-happen/index.js:267:17)
48 verbose stack     at /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/make-fetch-happen/index.js:139:14
49 verbose cwd /Users/anentropic/Documents/Dev/Work/MyJob/myproject
50 verbose Darwin 19.6.0
51 verbose argv "/Users/anentropic/.nvm/versions/node/v14.16.1/bin/node" "/Users/anentropic/.nvm/versions/node/v14.16.1/bin/npm" "install" "-g" "npm@7.14.0"
52 verbose node v14.16.1
53 verbose npm  v7.9.0
54 error code MODULE_NOT_FOUND
55 error Cannot find module 'agentkeepalive'
55 error Require stack:
55 error - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
55 error - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
55 error - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
55 error - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/pacote/lib/remote.js
55 error - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/pacote/lib/git.js
55 error - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
55 error - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/pacote/lib/index.js
55 error - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/lib/utils/update-notifier.js
55 error - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/lib/cli.js
55 error - /Users/anentropic/.nvm/versions/node/v14.16.1/lib/node_modules/npm/bin/npm-cli.js
56 verbose exit 1

I'm on an Intel Mac (Catalina)

@darcyclarke darcyclarke added this to the OSS - Sprint 31 milestone Jun 1, 2021
isaacs added a commit to npm/make-fetch-happen that referenced this issue Jun 1, 2021
isaacs added a commit to npm/npm-package-arg that referenced this issue Jun 1, 2021
@Jalle19
Copy link

Jalle19 commented Jun 16, 2021

This happened to me today as well (Ubuntu 20.04, x86_64, Node.js v14.15.4, npm was 7.12.1):

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

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/negge/.npm/_logs/2021-06-16T12_14_22_335Z-debug.log

I got the command from:

npm notice 
npm notice New minor version of npm available! 7.12.1 -> 7.17.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.17.0
npm notice Run npm install -g npm@7.17.0 to update!
npm notice

Dropping the version constraint worked:

$ npm install -g npm

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

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

found 0 vulnerabilities
$ npm --version
7.17.0

Please consider fixing this bug or at least changing the suggested upgrade command.

@wraithgar
Copy link
Member

This bug was fixed in v7.17.0 and was due to some lazy loading of agentkeepalive in a subdependency of npm-registry-fetch. It should not happen in versions going forward.

ref: e92b5f2

@wraithgar
Copy link
Member

If you are consistently getting this error, and omitting the version does not work, you can install the newest npm via our install script:

$ curl -qs https://www.npmjs.com/install.sh|sh

@Philogy
Copy link

Philogy commented Aug 15, 2021

Same on Big Sur 16" MBP 2019. I predict 3,000 "me too" comments coming soon.

Perhaps obviously, installing agentkeepalive will then allow you to upgrade your npm: npm i -g agentkeepalive

Thanks, fixed it for me!

@dmatranga
Copy link

Same on Big Sur 16" MBP 2019. I predict 3,000 "me too" comments coming soon.
Perhaps obviously, installing agentkeepalive will then allow you to upgrade your npm: npm i -g agentkeepalive

Thanks, fixed it for me!

Same here, thank you.

@liambowers
Copy link

I've just come across this issue and what solved it in my case was switching node (using nvm) from v14.15.1 to v14.17.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests