最近入手了一款M2 pro芯片的mac,在使用nvm来管理node版本的时候发现在安装nodeV14.x版本的出现死循环的情况具体输出如下
nvm install 14.19.0
Downloading and installing node v14.19.0...
Downloading https://nodejs.org/dist/v14.19.0/node-v14.19.0-darwin-arm64.tar.xz...
curl: (22) The requested URL returned error: 404
Binary download from https://nodejs.org/dist/v14.19.0/node-v14.19.0-darwin-arm64.tar.xz failed, trying source.
grep: /Users/xuyuejin/.nvm/.cache/bin/node-v14.19.0-darwin-arm64/node-v14.19.0-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 10 CPU core(s)
Running with 9 threads to speed up the build
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
Local cache found: ${NVM_DIR}/.cache/src/node-v14.19.0/node-v14.19.0.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/src/node-v14.19.0/node-v14.19.0.tar.xz
$>./configure --prefix=/Users/xuyuejin/.nvm/versions/node/v14.19.0 <
Node.js configure: Found Python 3.9.6...
INFO: configure completed successfully
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C out BUILDTYPE=Release
解决方案
执行install命令前先执行M2兼容命令:
arch -x86_64 zsh
然后再执行install就OK了