4

M1 executes nvm install to install node and reports error 404

 ➜  sales_app git:(carDetail) nvm install 12.22.12
Downloading and installing node v12.22.12...
Downloading https://nodejs.org/dist/v12.22.12/node-v12.22.12-darwin-arm64.tar.xz...
-#O=-#      #        #                                                                                                                                                                                                        
curl: (22) The requested URL returned error: 404 
Binary download from https://nodejs.org/dist/v12.22.12/node-v12.22.12-darwin-arm64.tar.xz failed, trying source.
grep: /Users/gch/.nvm/.cache/bin/node-v12.22.12-darwin-arm64/node-v12.22.12-darwin-arm64.tar.xz: No such file or directory
Provided file to checksum does not exist.
Binary download failed, trying source.
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
Local cache found: $NVM_DIR/.cache/src/node-v12.22.12/node-v12.22.12.tar.xz
Checksums match! Using existing downloaded archive $NVM_DIR/.cache/src/node-v12.22.12/node-v12.22.12.tar.xz
$>./configure --prefix=/Users/gch/.nvm/versions/node/v12.22.12 <
INFO: configure completed successfully
/Library/Developer/CommandLineTools/usr/bin/make -C out BUILDTYPE=Release V=0
  touch /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/node_dtrace_header.stamp
  touch /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/specialize_node_d.stamp
  touch /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/tools/v8_gypfiles/v8_headers.stamp
  c++ -o /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/icui18n/deps/icu-small/source/i18n/nultrans.o ../deps/icu-small/source/i18n/nultrans.cpp '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DOPENSSL_NO_ASM' '-DU_I18N_IMPLEMENTATION=1' '-DU_ATTRIBUTE_DEPRECATED=' '-D_CRT_SECURE_NO_DEPRECATE=' '-DU_STATIC_IMPLEMENTATION=1' '-DUCONFIG_NO_SERVICE=1' '-DU_ENABLE_DYLOAD=0' '-DU_HAVE_STD_STRING=1' '-DUCONFIG_NO_BREAK_ITERATION=0' -I../deps/icu-small/source/i18n -I../deps/icu-small/source/common  -O3 -gdwarf-2 -mmacosx-version-min=10.10 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++1y -stdlib=libc++ -fno-exceptions -fno-strict-aliasing -MMD -MF /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/.deps//Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/icui18n/deps/icu-small/source/i18n/nultrans.o.d.raw   -c
  c++ -o /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/icui18n/deps/icu-small/source/i18n/uspoof_conf.o ../deps/icu-small/source/i18n/uspoof_conf.cpp '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DOPENSSL_NO_ASM' '-DU_I18N_IMPLEMENTATION=1' '-DU_ATTRIBUTE_DEPRECATED=' '-D_CRT_SECURE_NO_DEPRECATE=' '-DU_STATIC_IMPLEMENTATION=1' '-DUCONFIG_NO_SERVICE=1' '-DU_ENABLE_DYLOAD=0' '-DU_HAVE_STD_STRING=1' '-DUCONFIG_NO_BREAK_ITERATION=0' -I../deps/icu-small/source/i18n -I../deps/icu-small/source/common  -O3 -gdwarf-2 -mmacosx-version-min=10.10 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++1y -stdlib=libc++ -fno-exceptions -fno-strict-aliasing -MMD -MF /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/.deps//Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/icui18n/deps/icu-small/source/i18n/uspoof_conf.o.d.raw   -c

After analysis, it is found that when the node version is installed by the command, the automatic splicing path of the M1 computer is as follows:

https://nodejs.org/dist/v12.22.12/node-v12.22.12-darwin-arm64.tar.xz

arm64 is a software command method unique to M1. At present, the official website of node does not provide such compressed packages. The official website of compressed packages

image-20220801173458645

solution

Execute the M1 compatible command before executing the install command:

arch -x86_64 zsh

Then executing install will automatically fix the link to the downloaded version:

https://nodejs.org/dist/v12.22.0/node-v12.22.0-darwin-x64.tar.xz
 ➜  ~ arch -x86_64 zsh
➜  ~ nvm install 12.22.0         
Downloading and installing node v12.22.0...
Downloading https://nodejs.org/dist/v12.22.0/node-v12.22.0-darwin-x64.tar.xz...
###################################################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v12.22.0 (npm v6.14.11)

兰俊秋雨
5.1k 声望3.5k 粉丝

基于大前端端技术的一些探索反思总结及讨论