文章目录
建议安装过程中多多结合【参考】中的内容。
1. Mac 安装 Node JS 11 环境
前提是已经安装 Homebrew。
1.1 uninstall node
brew uninstall --force node # 卸载已经安装的node
brew update # 更新brew
1.2 安装 nvm
node js 也可以下载安装,选择下载版本地址:https://nodejs.org/dist/
nvm,即 node version manager 的缩写,node js 的版本管理工具。
brew install nvm
查看是否安装成功
nvm --version
1.3 nvm 11
查看远程 node js 版本
nvm ls-remote
更新 node js 11 这个版本
nvm install 11
使用 node js 11 这个版本
nvm ls
nvm use 11
Now using node v11.15.0 (npm v6.7.0),表示成功了。
2. 报错处理
2.1 安装nvm报错
报错信息:
make[1]: *** Waiting for unfinished jobs.... rm 490f1fcf42b2afac71d1c00fb593c736d4a65552.intermediate make: *** [node] Error 2 nvm: install v11.15.0 failed!
解决办法:
更新npm,更行npm的时候会自动将node更新
➜ ~ npm --version
zsh: command not found: npm
➜ ~ brew install npm

2.2 安装 nvm 报错
报错:
curl: (6) Could not resolve host: codeload.github.com Error: Failed to download resource "nvm" Download failed: https://github.com/creationix/nvm/archive/v0.37.2.tar.gz
浏览器里打开 https://github.com/creationix/nvm/archive/v0.37.2.tar.gz 试了一下不行,无法访问。
又尝试了下面的方法安装,参考[2]。
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
报错:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
解决步骤:
- 打开 https://www.ipaddress.com/,搜索 raw.githubusercontent.com 对应的IP 地址

- 编辑并替换host文件
打开Finder,cmd+G,打开 etc 目录,复制一份 hosts 文件出来

添加199.232.96.133 raw.githubusercontent.com

将原来的hosts文件替换掉。
- 重新安装
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
安装完之后需要关闭终端重新打开,才能使用 nvm。
上述步骤是参考了“参考[3]”中的解决方案这个问题就解决的。
3. 参考
[1] Mac OS 下 NVM 的安装与使用:https://www.jianshu.com/p/622ad36ee020
[2] nvm-sh/nvm: https://github.com/nvm-sh/nvm/blob/master/README.md
[3] curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused的几种解决方式: https://blog.csdn.net/qq_43531694/article/details/106862753
[4] NodeJs安装错误汇总: https://blog.csdn.net/mergerly/article/details/50548848
[5] Mac 如何安装 nodejs: https://blog.csdn.net/qq_32407233/article/details/83758899
本文介绍在Mac上安装Node JS 11环境的步骤,前提是已安装Homebrew,包括卸载node、安装nvm、更新和使用Node JS 11版本。同时针对安装nvm时出现的报错给出解决办法,如更新npm、替换host文件等,还提供了相关参考资料。

1928

被折叠的 条评论
为什么被折叠?



