Skip to content

NVM: Fallback to .tar.gz for darwin-arm64 binary when .tar.xz is 404 (e.g., Node 14.x) #3588

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

Open
sayymeer opened this issue May 21, 2025 · 4 comments
Labels
pull request wanted This is a great way to contribute! Help us out :-D

Comments

@sayymeer
Copy link

Operating system and version:

nvm debug output:

nvm --version: v0.40.3
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'user'
${HOME}: /Users/user
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v14.21.3/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 (arm64-apple-darwin24.0)'
uname -a: 'Darwin 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6041 arm64'
checksum binary: 'sha256sum'
OS version: macOS 15.5 24F74
awk: /usr/bin/awk, awk version 20200816
curl: /usr/bin/curl, curl 8.7.1 (x86_64-apple-darwin24.0) libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.64.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.5 (Apple Git-154)
grep: /usr/bin/grep, grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
nvm current: v14.21.3
which node: ${NVM_DIR}/versions/node/v14.21.3/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v14.21.3/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v14.21.3
npm root -g: ${NVM_DIR}/versions/node/v14.21.3/lib/node_modules

nvm ls output:

->     v14.21.3
       v18.20.8
         system
default -> lts/hydrogen (-> v18.20.8)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.20.8) (default)
stable -> 18.20 (-> v18.20.8) (default)
lts/* -> lts/jod (-> 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
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.20.8
lts/iron -> v20.19.2 (-> N/A)
lts/jod -> v22.15.1 (-> N/A)

How did you install nvm?

Using brew

What steps did you perform?

  1. Attempted to install Node.js v14.x (specifically tried nvm install 14, nvm install 14.21.3, and nvm install 14.18.0) on an Apple Silicon (arm64) Mac.
  2. Observed NVM attempting to download a darwin-arm64.tar.xz binary.

What happened?

For certain Node.js v14.x versions (e.g., v14.18.0), NVM tried to download a darwin-arm64.tar.xz binary from https://nodejs.org/dist/. This resulted in a curl: (56) The requested URL returned error: 404 because the .tar.xz version of the darwin-arm64 binary does not exist for that specific Node version.
However, a darwin-arm64.tar.gz binary does exist on the server for that same Node version (e.g., https://nodejs.org/dist/v14.18.0/node-v14.18.0-darwin-arm64.tar.gz).
Because the .tar.xz download failed, NVM fell back to compiling from source. This fallback can also fail due to other incompatibilities (e.g., modern Python versions, newer Clang compiler issues with old Node 14 source), which could be avoided if the available .tar.gz binary was used.

What did you expect to happen?

I expected NVM to successfully download and install a pre-compiled darwin-arm64 binary for Node.js v14.x if one was available on nodejs.org/dist/.
Specifically, if NVM fails to find a .tar.xz binary but a .tar.gz binary exists for the target version and architecture (darwin-arm64 in this case), NVM should ideally attempt to download and use the .tar.gz archive before falling back to source compilation.

I successfully got it working by manually downloading the .tar.gz Node.js archive. After unarchiving it, I placed the contents into the correct NVM versions folder, and it's now operational.

Additional context / willingness to contribute:

I've manually verified that for versions like Node v14.18.0, the darwin-arm64.tar.gz binary is available on nodejs.org/. This forces an unnecessary (and often problematic for older Node versions on modern macOS) fallback to source compilation.

I am interested in exploring how to contribute a fix for this, perhaps by adding logic to check for and use the .tar.gz archive if the .tar.xz attempt results in a 404 for these specific darwin-arm64 cases.

@ljharb
Copy link
Member

ljharb commented May 21, 2025

Note that nvm installed with brew is unsupported (as the formula tells you); please remove it and install it using the official installation script.

Additionally, node < 16 on ARM requires a rosetta terminal afaik - I'm not sure what the deal is with that node 14.18 binary.

@sayymeer
Copy link
Author

sayymeer commented May 22, 2025

Can you please explain why is it so? Why it is unsupported (I am new to open source).

--Update--
I installed nvm using official script. Getting same error.

> nvm install 14
Downloading and installing node v14.21.3...
Downloading https://nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-arm64.tar.xz...
curl: (56) The requested URL returned error: 404

download from https://nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-arm64.tar.xz failed
grep: /Users/syadav27/.nvm/.cache/bin/node-v14.21.3-darwin-arm64/node-v14.21.3-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 14 CPU core(s)
Running with 13 threads to speed up the build
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
Downloading https://nodejs.org/dist/v14.21.3/node-v14.21.3.tar.xz...
############################################################################################################################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!

And building from source get failed.

@ljharb
Copy link
Member

ljharb commented May 22, 2025

Primarily because I don't distribute nvm there, which makes it unofficial, and software should only be installed from official distribution channels - but in the specific case of brew, the user experience is severely degraded, and i don't want my users to blame nvm for that.

What happens if you follow the instructions in the readme for using a Rosetta terminal?

@sayymeer
Copy link
Author

I have followed the readme instruction (also using rosetta).

@ljharb ljharb added the pull request wanted This is a great way to contribute! Help us out :-D label May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull request wanted This is a great way to contribute! Help us out :-D
Projects
None yet
Development

No branches or pull requests

2 participants