Mac 安装 Node JS 11 环境

建议安装过程中多多结合【参考】中的内容。

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

解决步骤:

  1. 打开 https://www.ipaddress.com/,搜索 raw.githubusercontent.com 对应的IP 地址

在这里插入图片描述

  1. 编辑并替换host文件

打开Finder,cmd+G,打开 etc 目录,复制一份 hosts 文件出来

在这里插入图片描述

添加199.232.96.133 raw.githubusercontent.com

在这里插入图片描述
将原来的hosts文件替换掉。

  1. 重新安装
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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Morris_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值