nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lts/fermium (v14.21.2) installing wrong version of npm (9x)

georgegray-418 opened this issue · comments

Operating system and version:

nvm debug output:

~  nvm debug
nvm --version: v0.39.1
$TERM_PROGRAM: Apple_Terminal
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'georgegray'
${HOME}: /Users/georgegray
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /Library/Java/JavaVirtualMachines/jdk-11.0.16.jdk/Contents/Home/bin:${NVM_DIR}/versions/node/v14.21.2/bin:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.8.1 (x86_64-apple-darwin21.0)'
uname -a: 'Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64'
checksum binary: 'shasum'
OS version: macOS 12.4 21F79
curl: /usr/bin/curl, curl 7.79.1 (x86_64-apple-darwin21.0) libcurl/7.79.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.45.1
wget: /opt/homebrew/bin/wget, GNU Wget 1.21.3 built on darwin21.3.0.
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.32.1 (Apple Git-133)
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
awk: /usr/bin/awk, awk version 20200816
nvm current: v14.21.2
which node: ${NVM_DIR}/versions/node/v14.21.2/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v14.21.2/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v14.21.2
npm root -g: ${NVM_DIR}/versions/node/v14.21.2/lib/node_modules

nvm ls output:

~ nvm ls 
       v14.20.0
       v14.20.1
       v14.21.1
->     v14.21.2
       v16.16.0
       v16.17.0
       v16.17.1
       v16.18.0
       v16.18.1
       v16.19.0
default -> lts/gallium (-> v16.19.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v16.19.0) (default)
stable -> 16.19 (-> v16.19.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.2
lts/gallium -> v16.19.0
lts/hydrogen -> v18.12.1 (-> N/A)

How did you install nvm?

homebrew

What steps did you perform?

nvm install lts/fermium

What happened?

npm v9x was installed

v14.21.2 is already installed.
Now using node v14.21.2 (npm v9.2.0)

What did you expect to happen?

npm 6x be installed.

According to the nodejs.org releases page the latest Fermium (2022-12-13) should pair with npm 6.14.17. Not v9.2.0.

v14.21.2 is already installed.
Now using node v14.21.2 (npm v6.14.17)

What does which npm say?

What does which npm say?

/Users/georgegray/.nvm/versions/node/v14.21.2/bin/npm

and npm --version still says v9? that's very strange. Do you have a $NVM_DIR/default-packages file?

$NVM_DIR/default-packages

Looks like I do not.

~  npm --version                                                                                                                                                                             
9.2.0

~  cat $NVM_DIR/default-packages                                                                                                                                                             
cat: /Users/georgegray/.nvm/default-packages: No such file or directory

Incidentally, installing the previous lts version nvm install v14.21.1 Gives me the correct version of npm, I'm guessing from your responses you cant reproduce locally?

no, i have npm v6.14.17.

There's only a few ways nvm should be capable of updating your nvm-managed npm:

  1. nvm install-latest-npm (or --latest-npm when installing)
  2. having npm in the default-packages file
  3. nvm reinstall-packages X (or --reinstall-packages-from=X when installing) where X is a node version with npm 9

However, since it said "was already installed", is there any chance it'd been previously updated? Meaning, if you nvm uninstall 14.21.2 && nvm install 14.21.2, what npm do you get?

~ nvm uninstall 14.21.2 && nvm install 14.21.2                                                                                                                           
Uninstalled node v14.21.2
Downloading and installing node v14.21.2...
Local cache found: ${NVM_DIR}/.cache/bin/node-v14.21.2-darwin-x64/node-v14.21.2-darwin-x64.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v14.21.2-darwin-x64/node-v14.21.2-darwin-x64.tar.xz
Now using node v14.21.2 (npm v6.14.17)

Looks to have fixed it, I think some of our build automation may be at fault, thanks for your help!