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

nvm install-latest-npm fails with "Cannot find module 'agentkeepalive'" #2438

Closed
JakobJingleheimer opened this issue Feb 15, 2021 · 35 comments
Closed
Labels
needs followup We need some info or action from whoever filed this issue/PR. OS: Mac OS

Comments

@JakobJingleheimer
Copy link

Operating system and version:

macOS 11.2 Big Sur

nvm debug output:

nvm --version: v0.37.2
$TERM_PROGRAM: Apple_Terminal
$SHELL: /bin/bash
$SHLVL: 1
whoami: ***
${HOME}: ***
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:${NVM_DIR}/versions/node/v15.8.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:/usr/local/git/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 3.2.57(1)-release (arm64-apple-darwin20)'
uname -a: 'Darwin 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64'
checksum binary: 'shasum'
OS version: macOS 11.2 20D64
curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin20.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0
wget: not found
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/local/bin/git, git version 2.30.0
grep: /usr/bin/grep, grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20200816
nvm current: v15.8.0
which node: ${NVM_DIR}/versions/node/v15.8.0/bin/node
which iojs: 
which npm: ${NVM_DIR}/versions/node/v15.8.0/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v15.8.0
npm root -g: ${NVM_DIR}/versions/node/v15.8.0/lib/node_modules

nvm ls output:

        v15.6.0
->      v15.8.0
default -> node (-> v15.8.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v15.8.0) (default)
stable -> 15.8 (-> v15.8.0) (default)
lts/* -> lts/fermium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.23.3 (-> N/A)
lts/erbium -> v12.20.2 (-> N/A)
lts/fermium -> v14.15.5 (-> N/A)

How did you install nvm?

What steps did you perform?

What happened?

I installed the latest version of NodeJS and forgot to include the extra --latest-npm flag. After node v15.8 finished, I ran nvm install-latest-npm

nvm command output
Attempting to upgrade to the latest working version of npm...
* Installing latest `npm`; if this does not work on your node version, please report a bug!
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:
npm ERR! - …/.nvm/versions/node/v15.8.0/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
npm ERR! - …/.nvm/versions/node/v15.8.0/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
npm ERR! - …/.nvm/versions/node/v15.8.0/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
npm ERR! - …/.nvm/versions/node/v15.8.0/lib/node_modules/npm/node_modules/pacote/lib/remote.js
npm ERR! - …/.nvm/versions/node/v15.8.0/lib/node_modules/npm/node_modules/pacote/lib/git.js
npm ERR! - …/.nvm/versions/node/v15.8.0/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
npm ERR! - …/.nvm/versions/node/v15.8.0/lib/node_modules/npm/node_modules/pacote/lib/index.js
npm ERR! - …/.nvm/versions/node/v15.8.0/lib/node_modules/npm/lib/utils/update-notifier.js
npm ERR! - …/.nvm/versions/node/v15.8.0/lib/node_modules/npm/lib/cli.js
npm ERR! - …/.nvm/versions/node/v15.8.0/lib/node_modules/npm/bin/npm-cli.js
@ljharb
Copy link
Member

ljharb commented Feb 15, 2021

For node 15, this is the same as npm install -g npm, so presumably that command fails in the same way?

@ljharb
Copy link
Member

ljharb commented Feb 15, 2021

Also, are you on an M1 mac?

@ljharb ljharb added needs followup We need some info or action from whoever filed this issue/PR. OS: Mac OS labels Feb 15, 2021
@JakobJingleheimer
Copy link
Author

I did not try npm install -g npm

Yes, M1 Mac

@ljharb
Copy link
Member

ljharb commented Feb 15, 2021

How did you install node on an M1 Mac? (I'm asking since node isn't supported there, so I don't know which workaround you used, and that might affect some dependencies of npm).

Can you try npm install -g npm please?

@JakobJingleheimer
Copy link
Author

JakobJingleheimer commented Feb 15, 2021

I used nvm: nvm install node (which installed v15.6.0, the latest at the time).

Sure, I can try installing npm with npm later today

EDIT: node was original ported over to my M1 mac via Time Machine from a previous installation from an intel-based mac. That version had been installed via homebrew; then I needed to have an older version to test a regression, so I foolishly installed via the official nodejs.org installer. I uninstalled that version (what a pain in the a**) and also the homebrew one and installed the latest via nvm (that version had not been previously installed at all).

@ljharb
Copy link
Member

ljharb commented Feb 15, 2021

Ah, then presumably your terminal is running in rosetta emulation mode?

@JakobJingleheimer
Copy link
Author

Yes, I think I saw that somewhere. Do you know how to verify that?

@ljharb
Copy link
Member

ljharb commented Feb 15, 2021

I believe node -p process.arch will print out arm64 when it's for the M1 chip, and x64 for the rosetta one. See the "Macs with M1 chip" section in the readme.

@JakobJingleheimer
Copy link
Author

$> node -p process.arch
x64

@JakobJingleheimer
Copy link
Author

npm install -g npm fails with the same error.

@ljharb
Copy link
Member

ljharb commented Feb 15, 2021

Just to be clear: you're seeing this problem both on node 15.6 (that you'd previously installed) as well as a newly-installed node 15.8?

@JakobJingleheimer
Copy link
Author

No: 15.6 (installed with nvm) was fine, no errors. The latest npm was also installed at the same time.

@ljharb
Copy link
Member

ljharb commented Feb 15, 2021

Can you try nvm install 15.7 --latest-npm now? I'm wondering if this is a bug in npm v7.5.3 - since node 15.7 came with npm v7.4.3, that would eliminate that possibility.

@bulganerdenebaatar
Copy link

@ljharb I was having the same issue on m1 mac. this command nvm install 15.7 --latest-npm resolved the issues. Thanks

@JakobJingleheimer
Copy link
Author

JakobJingleheimer commented Feb 15, 2021

No dice. But I think something else unrelated is happening here

$> nvm install 15.7 --latest-npm

Downloading and installing node v15.7.0...
Downloading https://nodejs.org/dist/v15.7.0/node-v15.7.0-darwin-arm64.tar.xz...
#=#=#                                                                          
curl: (22) The requested URL returned error: 404 
Binary download from https://nodejs.org/dist/v15.7.0/node-v15.7.0-darwin-arm64.tar.xz failed, trying source.
grep: /Users/jshado1/.nvm/.cache/bin/node-v15.7.0-darwin-arm64/node-v15.7.0-darwin-arm64.tar.xz: No such file or directory
Provided file to checksum does not exist.
Binary download failed, trying source.
Detected that you have 8 CPU core(s)
Running with 7 threads to speed up the build
Additional options while compiling:  --latest-npm
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
Downloading https://nodejs.org/dist/v15.7.0/node-v15.7.0.tar.xz...
######################################################################### 100.0%
Computing checksum with shasum -a 256

Checksums matched!
$>./configure --prefix=/Users/jshado1/.nvm/versions/node/v15.7.0 --latest-npm<
Node.js configure: Found Python 3.9.1...
gyp: --latest-npm not found (cwd: /Users/jshado1/.nvm/.cache/src/node-v15.7.0/files) while trying to load --latest-npm
Error running GYP
nvm: install v15.7.0 failed!

@ljharb
Copy link
Member

ljharb commented Feb 15, 2021

@JakobJingleheimer that error is due to node having no support for M1 Macs, and you'll need to follow the steps in the M1 section of the readme to ensure your shell is in the emulated architecture when installing node.

@JakobJingleheimer
Copy link
Author

Hmm, strangely I didn't have any trouble installing 15.6 or 15.8. I'll try those special M1 instructions though (thanks!)

@ljharb
Copy link
Member

ljharb commented Feb 19, 2021

It also might be a bug with the npm version that ships with 15.7.

@JakobJingleheimer
Copy link
Author

JakobJingleheimer commented Feb 19, 2021

It is something to do with 15.7. I just checked. Also after setting arch -x86_64 bash, I installed node 15.9 + npm 7.5.3 no problem. Curiously, I included --latest-npm and it installed 7.5.3 instead of the actual latest (7.5.4)

npm i -g npm@latest still fails with the Cannot find module 'agentkeepalive' error though (inside the arch x64 bash)

@ljharb
Copy link
Member

ljharb commented Feb 19, 2021

hm, 7.5.4 should def be installed; if npm install -g npm doesn’t do it, then I’d file a cli bug.

@MKYounis

This comment has been minimized.

@dinhkhanh

This comment has been minimized.

@mikeyfe6
Copy link

nvm install-latest-npm worked for me guys..

@richarddewit
Copy link

richarddewit commented Mar 24, 2021

Hm weird. I had the same error, but when I used nvm use (ran out of other options), the install worked. (Yes I used it before, but that was some days ago, so I was on the same version)

@nagkumar
Copy link

Installing this

npm install -g agentkeepalive --save

then upgrading npm worked for me.

@luciusinspace

This comment has been minimized.

@JakobJingleheimer
Copy link
Author

JakobJingleheimer commented Mar 28, 2021

Strangely, nvm install-latest-npm (and then nvm install node) succeeds yet nvm install node --latest-npm fails 🤷‍♂️

(I didn't have to set arch beforehand)

I updated from npm 7.6.0 → 7.7.5, and node 15.11.0 → 15.12.0

@ljharb
Copy link
Member

ljharb commented Mar 28, 2021

@JakobJingleheimer the order to make those the same would have to be nvm install node, and then nvm install-latest-npm.

@JakobJingleheimer
Copy link
Author

I'm sure what you mean @ljharb, but I did have to run nvm install-latest-npm again after nvm install node because the latter installed an older version of npm (something like 7.6.3, instead of the current 7.7.5)

@ljharb
Copy link
Member

ljharb commented Mar 29, 2021

@JakobJingleheimer i just mean, "nvm install-latest-npm and then nvm install node" isn't the same as "nvm install node --latest-npm". "nvm install node --latest-npm" is the same as nvm install node && nvm install-latest-npm - note the reversed order.

@tschaub
Copy link

tschaub commented Mar 29, 2021

Reading the comments, it isn't clear to me how this issue was resolved.

Here is what I am seeing ([email protected], [email protected], [email protected]):

nvm install-latest-npm
Attempting to upgrade to the latest working version of npm...
nvm_install_latest_npm:68: command not found: 0
nvm_install_latest_npm:74: command not found: 0
* Installing latest `npm`; if this does not work on your node version, please report a bug!
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:
npm ERR! - /Users/tschaub/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
npm ERR! - /Users/tschaub/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
npm ERR! - /Users/tschaub/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
npm ERR! - /Users/tschaub/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/pacote/lib/remote.js
npm ERR! - /Users/tschaub/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/pacote/lib/git.js
npm ERR! - /Users/tschaub/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
npm ERR! - /Users/tschaub/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/pacote/lib/index.js
npm ERR! - /Users/tschaub/.nvm/versions/node/v14.16.0/lib/node_modules/npm/lib/utils/update-notifier.js
npm ERR! - /Users/tschaub/.nvm/versions/node/v14.16.0/lib/node_modules/npm/lib/cli.js
npm ERR! - /Users/tschaub/.nvm/versions/node/v14.16.0/lib/node_modules/npm/bin/npm-cli.js

And npm install -g npm@latest fails with the same stack.

Was this closed because it is a problem with npm instead of nvm?

Update

I found nodejs/help#3207 and saw the suggestion to run npm install -g npm (without latest or a version specified). This appears to have fixed the problem for me.

@HawaiiRyan
Copy link

I know this is closed, but 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

@ljharb
Copy link
Member

ljharb commented Apr 4, 2021

@HawaiiRyan this is an issue with npm; please file it there.

@acjbizar
Copy link

acjbizar commented Apr 8, 2021

I had the same feedback on Windows 10. Installing the latest Node, going from v14.16.0 to v15.14.0, fixed it for me.

@aravindvnair99
Copy link

aravindvnair99 commented Apr 8, 2021

@ljharb ljharb pinned this issue Apr 8, 2021
@ljharb ljharb unpinned this issue Apr 8, 2021
@nvm-sh nvm-sh locked as resolved and limited conversation to collaborators Apr 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs followup We need some info or action from whoever filed this issue/PR. OS: Mac OS
Projects
None yet
Development

No branches or pull requests