nvm icon indicating copy to clipboard operation
nvm copied to clipboard

npm requires node v0.2.3 or higher

Open UTGuy opened this issue 1 year ago • 4 comments

Operating system and version:

OSX Ventura 13.6 Apple M2

nvm debug output:

nvm --version: v0.39.5
$TERM_PROGRAM: Apple_Terminal
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'mlwalters'
${HOME}: /Users/mlwalters
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v20.7.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.9 (x86_64-apple-darwin22.0)'
uname -a: 'Darwin 22.6.0 Darwin Kernel Version 22.6.0: Fri Sep 15 13:39:54 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_ARM64_T8112 arm64'
checksum binary: 'shasum'
OS version: macOS 13.6 22G120
awk: /usr/bin/awk, awk version 20200816
curl: /usr/bin/curl, curl 8.1.2 (x86_64-apple-darwin22.0) libcurl/8.1.2 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.51.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: /opt/homebrew/bin/git, git version 2.42.0
ls: grep:: No such file or directory
grep: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}), grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
nvm current: none
which node: ${NVM_DIR}/versions/node/v20.7.0/bin/node
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:271: command not found: npm
npm root -g: nvm:271: command not found: npm

nvm ls output:

        v20.7.0
default -> 20 (-> v20.7.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v20.7.0) (default)
stable -> 20.7 (-> v20.7.0) (default)
lts/* -> lts/hydrogen (-> 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.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.18.0 (-> N/A)

How did you install nvm?

install script

What steps did you perform?

nvm install 20

What happened?

Downloading and installing node v20.7.0...
Local cache found: ${NVM_DIR}/.cache/bin/node-v20.7.0-darwin-arm64/node-v20.7.0-darwin-arm64.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v20.7.0-darwin-arm64/node-v20.7.0-darwin-arm64.tar.xz
Now using node v20.7.0
Installing npm...
npm requires node v0.2.3 or higher

What did you expect to happen?

This is a fresh install of NVM on a new laptop. I would have expected the installation of Node v20 to also install NPM properly.

Is there anything in any of your profile files that modifies the PATH?

No

UTGuy avatar Sep 28 '23 15:09 UTGuy

You have a homebrew-installed git, so it’s not quite a stock Mac laptop; you also have grep aliased, and nvm debug seems to imply that ls doesn’t exist?

Thees definitely something weird here, but the implication is that something in your profile is causing nvm to run the wrong command (which nvm can fix once it’s identified)

ljharb avatar Sep 28 '23 22:09 ljharb

I had the similar issue on Ubuntu and it turned out to be the PATH issue. Which I was able to fix by modifying bash like this: _

export PATH="$NVM_DIR/versions/node/$(nvm current)/bin:$PATH"

_ Hope that helps.

Margulis162 avatar Oct 08 '23 19:10 Margulis162

@ljharb I've uninstalled Homebrew git... I do have oh-my-zsh installed which could interfere with the aliaes for ls.

Couple of notes...

  • ls is aliased to ls -G through oh-my-zsh
  • grep is aliased to grep=grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} through oh-my-zsh
  • nvm install 20 seems to have worked but DOES NOT install npm (it does install node)

node -v output...

[1]    90534 killed     node -v

npm -v output...

zsh: command not found: npm

nvm debug output...

nvm --version: v0.39.5
$TERM_PROGRAM: Apple_Terminal
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'mlwalters'
${HOME}: /Users/mlwalters
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v20.8.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.9 (x86_64-apple-darwin22.0)'
uname -a: 'Darwin 22.6.0 Darwin Kernel Version 22.6.0: Fri Sep 15 13:39:54 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_ARM64_T8112 arm64'
checksum binary: 'shasum'
OS version: macOS 13.6 22G120
awk: /usr/bin/awk, awk version 20200816
curl: /usr/bin/curl, curl 8.1.2 (x86_64-apple-darwin22.0) libcurl/8.1.2 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.51.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/bin/git, git version 2.39.3 (Apple Git-145)
ls: grep:: No such file or directory
grep: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}), grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
nvm current: none
which node: ${NVM_DIR}/versions/node/v20.8.0/bin/node
which iojs: iojs not found
which npm: /usr/local/bin/npm
npm config get prefix: 
npm root -g: 

nvm ls output...

        v20.8.0
default -> 20 (-> v20.8.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v20.8.0) (default)
stable -> 20.8 (-> v20.8.0) (default)
lts/* -> lts/hydrogen (-> 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.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.18.0 (-> N/A)

With ls and grep unaliased you get...

grep: /usr/bin/grep, grep (BSD grep, GNU compatible) 2.6.0-FreeBSD

UTGuy avatar Oct 09 '23 13:10 UTGuy

npm comes with node, so it should be impossible to get node from nvm and not npm - but also your node -v output is incorrect. Are you sure node isn't aliased to something?

Either way, which npm prints out /usr/local/bin/npm which means you do have a (probably homebrew-installed) system version of npm. Remove that.

ljharb avatar Oct 09 '23 18:10 ljharb