Skip to content

Conversation

@Rahulbeniwal26119
Copy link

@Rahulbeniwal26119 Rahulbeniwal26119 commented Nov 16, 2025

This PR addresses the issue raised by #3588

  • For Node Version < 16.0.0 there are no amd64 binaries
  • Due to Resotta 2, x64 binaries can be run on new Macs
  • Existing logic was having an issue for node versions like 14.18.0, it looked for darwin-amd64 binaries
  • This PR updates the existing logic to make a stricter check for all versions less than 16.0.0
  • Added a few unit test cases to ensure that changes are behaving as expected.
> bash -c "source ./nvm.sh && nvm install 14.18.0"
Downloading and installing node v14.18.0...
Downloading https://nodejs.org/dist/v14.18.0/node-v14.18.0-darwin-x64.tar.xz...
######################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v14.18.0 (npm v6.14.15)
> uname -a 
Darwin Mac.lan 24.6.0 Darwin Kernel Version 24.6.0

Comment on lines -2363 to -2368
# If running MAC M1 :: Node v14.17.0 was the first version to offer official experimental support:
# https://github.com/nodejs/node/issues/40126 (although binary distributions aren't available until v16)
if \
nvm_version_greater '14.17.0' "${VERSION}" \
|| (nvm_version_greater_than_or_equal_to "${VERSION}" '15.0.0' && nvm_version_greater '16.0.0' "${VERSION}") \
; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm confused; this means that ^14.17 won't install directly on M* macs anymore.

Copy link
Author

@Rahulbeniwal26119 Rahulbeniwal26119 Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ljharb, the above check is used to set the x64 binary for all Macs running versions < 14.17.0, and for versions between 15 and 16. That’s why versions like 14.21.3 weren’t following this logic.

So either we can download the x64 binary for any version < 16, which would include 14.21.3 or, as you suggested here:

#3588 (comment)

I can add logic first to attempt downloading the ARM binary and use the x64 binary as a fallback. However, if we do this, I would also suggest removing the entire condition:

  if \
    nvm_version_greater '14.17.0' "${VERSION}" \
    || (nvm_version_greater_than_or_equal_to "${VERSION}" '15.0.0' && nvm_version_greater '16.0.0' "${VERSION}") \
  ; then

As we discussed for <16, there are no arm64 binaries. Please let me know which way is right.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://nodejs.org/dist/v14.18.0/ seems to have an arm binary listed?

Copy link
Author

@Rahulbeniwal26119 Rahulbeniwal26119 Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but this condition is for only arm64 + darwin. There is also an inner if condition after this

    if [ "_${NVM_OS}" = '_darwin' ] && [ "${NVM_ARCH}" = 'arm64' ]; then
      NVM_ARCH=x64
    fi

Let me combine these two so that it will be much more readable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installation Logs.

➜ nvm git:(fallback-to-x64-for-darwin-node-versions-less-than-16) source ./nvm.sh && nvm install 16.11.0
Downloading and installing node v16.11.0...
Downloading https://nodejs.org/dist/v16.11.0/node-v16.11.0-darwin-arm64.tar.xz...
######################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v16.11.0 (npm v8.0.0)

➜ nvm git:(fallback-to-x64-for-darwin-node-versions-less-than-16) source ./nvm.sh && nvm install 10.0.0
Downloading and installing node v10.0.0...
Downloading https://nodejs.org/dist/v10.0.0/node-v10.0.0-darwin-x64.tar.xz...
######################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v10.0.0 (npm v5.6.0)

➜ nvm git:(fallback-to-x64-for-darwin-node-versions-less-than-16) source ./nvm.sh && nvm install 14
Downloading and installing node v14.21.3...
Local cache found: ${NVM_DIR}/.cache/bin/node-v14.21.3-darwin-x64/node-v14.21.3-darwin-x64.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v14.21.3-darwin-x64/node-v14.21.3-darwin-x64.tar.xz
Now using node v14.21.3 (npm v6.14.18)

@Rahulbeniwal26119 Rahulbeniwal26119 force-pushed the fallback-to-x64-for-darwin-node-versions-less-than-16 branch from 951b758 to 0ff9272 Compare November 18, 2025 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants