nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
MIT License
79.32k stars 7.94k forks source link

nvm install node fails to install on macOS Big Sur M1 Chip #2350

Closed andyaccelerate closed 3 years ago

andyaccelerate commented 3 years ago

I'm trying to install the latest version of node using nvm. I've just got the newly released SIlicon Macbook Pro with the M1 chip (not sure if that is related). I've installed xcode on the app store and the xcode tools on the command line. The main error i'm getting is:

clang: error: no such file or directory: 'CXX=c++'

Full command output is at the bottom of the page.

Any help appreciated, Thanks

Operating system and version:

MacOS Big Sur

nvm debug output:

nvm --version: v0.33.0
$SHELL: /bin/zsh
$HOME: /Users/andy
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:119: command not found: npm
npm root -g: nvm:119: command not found: npm

nvm ls output:

N/A
node -> stable (-> N/A) (default)
iojs -> N/A (default)
lts/* -> lts/fermium (-> 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.23.0 (-> N/A)
lts/erbium -> v12.19.1 (-> N/A)
lts/fermium -> v14.15.1 (-> N/A)

How did you install nvm?

install script in readme

What steps did you perform?

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
nvm install node

What happened?

Downloading and installing node v15.2.1...
Local cache found: $NVM_DIR/.cache/bin/node-v15.2.1-darwin-arm64/node-v15.2.1-darwin-arm64.tar.gz
Computing checksum with shasum -a 256
Provided checksum to compare to is empty.
Checksum check failed!
Removing the broken local cache...
Downloading https://nodejs.org/dist/v15.2.1/node-v15.2.1-darwin-arm64.tar.gz...
##O#-  #                                                                                                                        
Computing checksum with shasum -a 256
Provided checksum to compare to is empty.
tar: Error opening archive: Unrecognized archive format
Binary download failed, trying source.
Local cache found: $NVM_DIR/.cache/src/node-v15.2.1/node-v15.2.1.tar.gz
Checksums match! Using existing downloaded archive $NVM_DIR/.cache/src/node-v15.2.1/node-v15.2.1.tar.gz
Node.js configure: Found Python 2.7.16...
INFO: configure completed successfully
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C out BUILDTYPE=Release V=0
  LD_LIBRARY_PATH=/Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/lib.host:/Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../.; mkdir -p /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj/gen; dtrace -h -xnolibs -s src/node_provider.d -o "/Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj/gen/node_provider.h"
  LD_LIBRARY_PATH=/Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/lib.host:/Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../.; mkdir -p /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release; tools/specialize_node_d.py "/Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/node.d" src/node.d mac arm64
  touch /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/tools/icu/icu_implementation.stamp
  touch /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/tools/icu/icu_uconfig.stamp
  touch /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/tools/icu/icu_uconfig_target.stamp
  touch /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.host/tools/icu/icu_implementation.stamp
  touch /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.host/tools/icu/icu_uconfig.stamp
  cc CXX=c++ -o /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/bio_ssl.o ../deps/openssl/openssl/ssl/bio_ssl.c '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DOPENSSL_NO_HW' '-DOPENSSL_NO_QUIC=1' '-DNDEBUG' '-DL_ENDIAN' '-DOPENSSL_PIC' '-DOPENSSL_CPUID_OBJ' '-DOPENSSL_BN_ASM_MONT' '-DSHA1_ASM' '-DSHA256_ASM' '-DSHA512_ASM' '-DKECCAK1600_ASM' '-DVPAES_ASM' '-DECP_NISTZ256_ASM' '-DPOLY1305_ASM' '-DOPENSSLDIR="/System/Library/OpenSSL/"' '-DENGINESDIR="/dev/null"' -I../deps/openssl/openssl -I../deps/openssl/openssl/include -I../deps/openssl/openssl/crypto -I../deps/openssl/openssl/crypto/include -I../deps/openssl/openssl/crypto/modes -I../deps/openssl/openssl/crypto/ec/curve448 -I../deps/openssl/openssl/crypto/ec/curve448/arch_32 -I../deps/openssl/config -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2 -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/include -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/crypto -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/crypto/include/internal  -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -Wno-missing-field-initializers -fno-strict-aliasing -MMD -MF /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/.deps//Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/bio_ssl.o.d.raw   -c
  cc CXX=c++ -o /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/d1_lib.o ../deps/openssl/openssl/ssl/d1_lib.c '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DOPENSSL_NO_HW' '-DOPENSSL_NO_QUIC=1' '-DNDEBUG' '-DL_ENDIAN' '-DOPENSSL_PIC' '-DOPENSSL_CPUID_OBJ' '-DOPENSSL_BN_ASM_MONT' '-DSHA1_ASM' '-DSHA256_ASM' '-DSHA512_ASM' '-DKECCAK1600_ASM' '-DVPAES_ASM' '-DECP_NISTZ256_ASM' '-DPOLY1305_ASM' '-DOPENSSLDIR="/System/Library/OpenSSL/"' '-DENGINESDIR="/dev/null"' -I../deps/openssl/openssl -I../deps/openssl/openssl/include -I../deps/openssl/openssl/crypto -I../deps/openssl/openssl/crypto/include -I../deps/openssl/openssl/crypto/modes -I../deps/openssl/openssl/crypto/ec/curve448 -I../deps/openssl/openssl/crypto/ec/curve448/arch_32 -I../deps/openssl/config -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2 -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/include -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/crypto -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/crypto/include/internal  -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -Wno-missing-field-initializers -fno-strict-aliasing -MMD -MF /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/.deps//Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/d1_lib.o.d.raw   -c
  cc CXX=c++ -o /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/d1_msg.o ../deps/openssl/openssl/ssl/d1_msg.c '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DOPENSSL_NO_HW' '-DOPENSSL_NO_QUIC=1' '-DNDEBUG' '-DL_ENDIAN' '-DOPENSSL_PIC' '-DOPENSSL_CPUID_OBJ' '-DOPENSSL_BN_ASM_MONT' '-DSHA1_ASM' '-DSHA256_ASM' '-DSHA512_ASM' '-DKECCAK1600_ASM' '-DVPAES_ASM' '-DECP_NISTZ256_ASM' '-DPOLY1305_ASM' '-DOPENSSLDIR="/System/Library/OpenSSL/"' '-DENGINESDIR="/dev/null"' -I../deps/openssl/openssl -I../deps/openssl/openssl/include -I../deps/openssl/openssl/crypto -I../deps/openssl/openssl/crypto/include -I../deps/openssl/openssl/crypto/modes -I../deps/openssl/openssl/crypto/ec/curve448 -I../deps/openssl/openssl/crypto/ec/curve448/arch_32 -I../deps/openssl/config -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2 -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/include -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/crypto -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/crypto/include/internal  -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -Wno-missing-field-initializers -fno-strict-aliasing -MMD -MF /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/.deps//Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/d1_msg.o.d.raw   -c
  cc CXX=c++ -o /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/d1_srtp.o ../deps/openssl/openssl/ssl/d1_srtp.c '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DOPENSSL_NO_HW' '-DOPENSSL_NO_QUIC=1' '-DNDEBUG' '-DL_ENDIAN' '-DOPENSSL_PIC' '-DOPENSSL_CPUID_OBJ' '-DOPENSSL_BN_ASM_MONT' '-DSHA1_ASM' '-DSHA256_ASM' '-DSHA512_ASM' '-DKECCAK1600_ASM' '-DVPAES_ASM' '-DECP_NISTZ256_ASM' '-DPOLY1305_ASM' '-DOPENSSLDIR="/System/Library/OpenSSL/"' '-DENGINESDIR="/dev/null"' -I../deps/openssl/openssl -I../deps/openssl/openssl/include -I../deps/openssl/openssl/crypto -I../deps/openssl/openssl/crypto/include -I../deps/openssl/openssl/crypto/modes -I../deps/openssl/openssl/crypto/ec/curve448 -I../deps/openssl/openssl/crypto/ec/curve448/arch_32 -I../deps/openssl/config -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2 -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/include -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/crypto -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/crypto/include/internal  -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -Wno-missing-field-initializers -fno-strict-aliasing -MMD -MF /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/.deps//Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/d1_srtp.o.d.raw   -c
  cc CXX=c++ -o /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/methods.o ../deps/openssl/openssl/ssl/methods.c '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DOPENSSL_NO_HW' '-DOPENSSL_NO_QUIC=1' '-DNDEBUG' '-DL_ENDIAN' '-DOPENSSL_PIC' '-DOPENSSL_CPUID_OBJ' '-DOPENSSL_BN_ASM_MONT' '-DSHA1_ASM' '-DSHA256_ASM' '-DSHA512_ASM' '-DKECCAK1600_ASM' '-DVPAES_ASM' '-DECP_NISTZ256_ASM' '-DPOLY1305_ASM' '-DOPENSSLDIR="/System/Library/OpenSSL/"' '-DENGINESDIR="/dev/null"' -I../deps/openssl/openssl -I../deps/openssl/openssl/include -I../deps/openssl/openssl/crypto -I../deps/openssl/openssl/crypto/include -I../deps/openssl/openssl/crypto/modes -I../deps/openssl/openssl/crypto/ec/curve448 -I../deps/openssl/openssl/crypto/ec/curve448/arch_32 -I../deps/openssl/config -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2 -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/include -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/crypto -I../deps/openssl/config/archs/darwin64-arm64-cc/asm_avx2/crypto/include/internal  -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -Wno-missing-field-initializers -fno-strict-aliasing -MMD -MF /Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/.deps//Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/methods.o.d.raw   -c
clang: error: no such file or directory: 'CXX=c++'
clang: error: no such file or directory: 'CXX=c++'
clang: error: no such file or directory: 'CXX=c++'
make[1]: *** [/Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/d1_msg.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [/Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/bio_ssl.o] Error 1
make[1]: *** [/Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/d1_lib.o] Error 1
clang: error: no such file or directory: 'CXX=c++'
clang: error: no such file or directory: 'CXX=c++'
make[1]: *** [/Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/methods.o] Error 1
make[1]: *** [/Users/andy/.nvm/.cache/src/node-v15.2.1/files/out/Release/obj.target/openssl/deps/openssl/openssl/ssl/d1_srtp.o] Error 1
make: *** [node] Error 2
nvm: install v15.2.1 failed!
Prophe1 commented 3 years ago

Has same issue, was problem with the Node version, so I downgraded from v16 to v14. And it worked.

levonter commented 3 years ago

Just fyi - if you set the Open using Rosetta option on Terminal.app or iTerm.app - you'll save yourself a lot of headache until more stuff works w/ aarch64 and the toolchain on the M1 macs. TBF, most if not all of this stuff already works on, e.g. Raspberry Pi or Amazon Graviton2 instances ... but, there's a lot of bad scripts that hard-code detections for macOS and do something differently ... it'll take awhile to get those sorted, I expect.

Wow! That's really really helpful! Saved me a lot of time and effort!

THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU

AlexeyJersey commented 3 years ago

Just fyi - if you set the Open using Rosetta option on Terminal.app or iTerm.app - you'll save yourself a lot of headache until more stuff works w/ aarch64 and the toolchain on the M1 macs. TBF, most if not all of this stuff already works on, e.g. Raspberry Pi or Amazon Graviton2 instances ... but, there's a lot of bad scripts that hard-code detections for macOS and do something differently ... it'll take awhile to get those sorted, I expect.

Thank you!

imaddi47 commented 2 years ago

Well, I think just using arch -x86_64 zsh won't solve our problem. Let us understand this in this way... -> If I am using shell script in which nvm will be used to install a specific version of node at the beginning and then execute further lined up commands. if I am using arch -x86_64 zsh, If will stop the execution of all other commands after arch -x86_64 zsh <~ this one until and unless we tap ctrl + c.

Usecase Example: 1

We can clearly see here that this approach can't be used in automation in mac m1 as it will start a new instance of zsh with x86_64 architecture and won't follow our script to execute next lined up commands... Ultimately our script stuck just after arch x86_64 command

image

But if modify this as:

image It is working fine because we temporarily modified "echo [can be other commands too]" for x86_64

Usecase Example: 2

Using the same approach for installing node using nvm

Problem if we are not using arch -x86_64

image

Problem if we are using arch -x86_64

image

Here is my solution:

Prerequisite:

~> install rosetta 2 using terminal otherwise arch -x86_64 won't work

$ /usr/sbin/softwareupdate --install-rosetta --agree-to-license

Solution:

#!/bin/zsh
# Just to get environment path for nvm
source ~/.zshrc

arch -x86_64 zsh -c ". ~/.zshrc && nvm install v12.13.0"
arch -x86_64 zsh -c ". ~/.zshrc && nvm use v12.13.0"
arch -x86_64 zsh -c ". ~/.zshrc && nvm alias default v12.13.0"

image

Since arch x86_64 create temporary instance of x86_64 architecture to execute , we are creating temporary zsh shell with x86_64 architecture to execute desired command. But again, since it is an inline new instance and it is unaware of the RC file. That's why we are sourcing RC file every time we want to execute third-party tools with their path in RC files.

Code breakdown

That's all!!! Hope this will help a lot to all of those automation developers who do not intended to use GUI for automating Mac M1

ljharb commented 2 years ago

@imaddi47 what do you think about a PR to automate those steps in nvm itself?

imaddi47 commented 2 years ago

@imaddi47 what do you think about a PR to automate those steps in nvm itself?

Sure! I would love to.

RichardWaters90 commented 2 years ago

quit the terminal right click - go to "get info" select "open in rosetta" this should allow nvm to install older versions

SSylvain1989 commented 2 years ago

quit the terminal right click - go to "get info" select "open in rosetta" this should allow nvm to install older versions

thanks for the help , i have this issue :

ERROR: Did not find a new enough assembler, install one or build with
       --openssl-no-asm.
       Please refer to BUILDING.md

anyone know how to fix that ? on MBA M1

thisiseesmaeel commented 2 years ago

I get the following error, running on a m1 chip macbook. Any idea how to deal with this one, worth to note that I have gone through all of the above solutions.

> Could not find node-14.16.0-darwin-arm64.tar.gz (org.nodejs:node:14.16.0).
        Searched in the following locations:
            https://nodejs.org/dist/v14.16.0/node-v14.16.0-darwin-arm64.tar.gz
imaddi47 commented 2 years ago

I get the following error, running on a m1 chip macbook. Any idea how to deal with this one, worth to note that I have gone through all of the above solutions.

> Could not find node-14.16.0-darwin-arm64.tar.gz (org.nodejs:node:14.16.0).
        Searched in the following locations:
            https://nodejs.org/dist/v14.16.0/node-v14.16.0-darwin-arm64.tar.gz

Have you updated nvm version to 0.39.1 because it is tested after merging this PR image

TimJi commented 1 year ago

before install

nvm upgrade
ljharb commented 1 year ago

@TimJi that's not a command this tool supports.

luyaozhi commented 1 year ago

( cd "$NVM_DIR" git fetch --tags origin git checkout git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1) ) && . "$NVM_DIR/nvm.sh"

luyaozhi commented 1 year ago

( cd "$NVM_DIR" git fetch --tags origin git checkout git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1) ) && 。“$NVM_DIR/nvm.sh”

升级nvm版本

mr250792 commented 1 year ago

For anyone wondering how to do this....

  1. Right click the app (Terminal, iTerm, etc.)
  2. Tap "Get Info"
  3. Select "Open using Rosetta"
  4. Restart terminal and you're good to go!

Screenshots

Screen Shot 2020-12-07 at 11 07 04 PM Screen Shot 2020-12-07 at 11 07 13 PM

It work well for me

thx ~

tips: need to restart iTerm app

In mac M2 chip

Its Terminal instead of iTerm and can be found in the Application/Utilities folder

ljharb commented 1 year ago

Not just with an M2; on all Macs. iTerm is just a commonly used userland shell.

Sinpo96 commented 9 months ago

For anyone wondering how to do this....

  1. Right click the app (Terminal, iTerm, etc.)
  2. Tap "Get Info"
  3. Select "Open using Rosetta"
  4. Restart terminal and you're good to go!

Screenshots

Screen Shot 2020-12-07 at 11 07 04 PM Screen Shot 2020-12-07 at 11 07 13 PM

It work well for me thx ~ tips: need to restart iTerm app

In mac M2 chip

Its Terminal instead of iTerm and can be found in the Application/Utilities folder

Thanks! It works for me,I'm M3

kerberw commented 9 months ago

I think it is time to update the docs on Rosetta now. This has been in for a good while: https://github.com/nvm-sh/nvm/pull/2657

ljharb commented 9 months ago

@kerberw PRs welcome :-)