美文网首页
Mac M1 使用 nvm 安装 node 不成功的问题

Mac M1 使用 nvm 安装 node 不成功的问题

作者: 侯工 | 来源:发表于2024-06-24 16:20 被阅读0次

首先说明一下,用的电脑是mac M1芯片报错信息如下:

Downloading and installing node v14.21.3...
ls: /sbin/init: No such file or directory
Downloading https://nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-arm64.tar.xz...
curl: (22) The requested URL returned error: 404                                                      
Binary download from https://nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-arm64.tar.xz failed, trying source.
grep: /Users/houyujie/.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 8 CPU core(s)
Running with 7 threads to speed up the build
ls: /sbin/init: No such file or directory
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
ls: /sbin/init: No such file or directory
Local cache found: ${NVM_DIR}/.cache/src/node-v14.21.3/node-v14.21.3.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/src/node-v14.21.3/node-v14.21.3.tar.xz
$>./configure --prefix=/Users/houyujie/.nvm/versions/node/v14.21.3 <
Node.js configure: Found Python 3.9.6...
INFO: configure completed successfully
... ...

解决思路:
1、去node 官网查v14.19.0的版本,发现没有node-v14.19.0-darwin-arm64/node-v14.19.0-darwin-arm64.tar.xz 文件,所以肯定下载不下来。
2、那怎么操作能安装这个版本呢,查了解决办法可以使用以下操作解决

修改 vi ~./zshrc 文件,修改如下:

autoload -Uz compinit
compinit
export PATH="/opt/homebrew/opt/node@12/bin:$PATH"
export PATH="/opt/homebrew/opt/node@14/bin:$PATH"
export PATH="/opt/homebrew/opt/node@16/bin:$PATH"
export PATH="/usr/local/bin:$PATH"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

然后执行 arch -x86_64 zsh 后再安装即可。

再次安装

nvm install 14.21.3

实测成功!!!

相关文章

网友评论

      本文标题:Mac M1 使用 nvm 安装 node 不成功的问题

      本文链接:https://www.haomeiwen.com/subject/omhdcjtx.html