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 requires node v0.2.3 or higher #3211

Open
UTGuy opened this issue Sep 28, 2023 · 4 comments
Open

npm requires node v0.2.3 or higher #3211

UTGuy opened this issue Sep 28, 2023 · 4 comments
Labels
needs followup We need some info or action from whoever filed this issue/PR.

Comments

@UTGuy
Copy link

UTGuy commented Sep 28, 2023

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

@ljharb
Copy link
Member

ljharb commented Sep 28, 2023

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)

@Margulis162
Copy link

Margulis162 commented Oct 8, 2023

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.

@ljharb ljharb added the needs followup We need some info or action from whoever filed this issue/PR. label Oct 8, 2023
@UTGuy
Copy link
Author

UTGuy commented Oct 9, 2023

@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

@ljharb
Copy link
Member

ljharb commented Oct 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs followup We need some info or action from whoever filed this issue/PR.
Projects
None yet
Development

No branches or pull requests

3 participants