使用nvm安装nodejs时报以下错误:
C:\Users\Administrator>nvm install 18.6.0
Downloading node.js version 18.6.0 (64-bit)...
Complete
Downloading npm version 8.13.2... Error while downloading https://github.com/npm/cli/archive/v8.13.2.zip
- Get https://github.com/npm/cli/archive/v8.13.2.zip: net/http: TLS handshake timeout
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x5c6eb0]
提示nodejs安装完成,但是npm下载失败,这一看就是网络原因,因为我看到了handshake timeout(握手超时)
字样,因为没有买梯子,所以只能想其他办法。
解决方式1:修改镜像源
修改nvm(windows默认路径C:\Users\Administrator\AppData\Roaming\nvm
)的配置文件settings.txt
,将下面两行代码拷贝进settings.txt文件内保存,其他内容不用动,然后打开一个新的命令行重新使用nvm安装nodejs即可。
node_mirror: http://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
如果想查看nodejs版本,可以使用nvm list available
:
C:\Users\Administrator>nvm list available
| CURRENT | LTS | OLD STABLE | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
| 18.6.0 | 16.16.0 | 0.12.18 | 0.11.16 |
| 18.5.0 | 16.15.1 | 0.12.17 | 0.11.15 |
| 18.4.0 | 16.15.0 | 0.12.16 | 0.11.14 |
| 18.3.0 | 16.14.2 | 0.12.15 | 0.11.13 |
| 18.2.0 | 16.14.1 | 0.12.14 | 0.11.12 |
| 18.1.0 | 16.14.0 | 0.12.13 | 0.11.11 |
| 18.0.0 | 16.13.2 | 0.12.12 | 0.11.10 |
| 17.9.1 | 16.13.1 | 0.12.11 | 0.11.9 |
| 17.9.0 | 16.13.0 | 0.12.10 | 0.11.8 |
| 17.8.0 | 14.20.0 | 0.12.9 | 0.11.7 |
| 17.7.2 | 14.19.3 | 0.12.8 | 0.11.6 |
| 17.7.1 | 14.19.2 | 0.12.7 | 0.11.5 |
| 17.7.0 | 14.19.1 | 0.12.6 | 0.11.4 |
| 17.6.0 | 14.19.0 | 0.12.5 | 0.11.3 |
| 17.5.0 | 14.18.3 | 0.12.4 | 0.11.2 |
| 17.4.0 | 14.18.2 | 0.12.3 | 0.11.1 |
| 17.3.1 | 14.18.1 | 0.12.2 | 0.11.0 |
| 17.3.0 | 14.18.0 | 0.12.1 | 0.9.12 |
| 17.2.0 | 14.17.6 | 0.12.0 | 0.9.11 |
| 17.1.0 | 14.17.5 | 0.10.48 | 0.9.10 |
This is a partial list. For a complete list, visit https://nodejs.org/download/release
安装nodejs:
C:\Users\Administrator>nvm install 18.6.0
Downloading node.js version 18.6.0 (64-bit)...
Complete
Downloading npm version 8.13.2... Complete
Installing npm v8.13.2...
Installation complete. If you want to use this version, type
nvm use 18.6.0
解决方式2:手动下载nodejs,修改文件夹名称,拷贝到nvm文件夹下
nodejs各个版本下载地址:https://registry.npmmirror.com/binary.html?path=node/
根据自己的电脑,选择一个版本的压缩文件下载,下载完成之后解压,然后修改名称为nvm支持的文件夹名称
修改文件夹名称为v16.13.1
使用nvm指令查看当前node以及npm是否可用:
C:\Users\Administrator>nvm list
18.6.0
16.16.0
16.15.1
16.13.1
* 14.19.3 (Currently using 64-bit executable)
C:\Users\Administrator>nvm use 16.13.1
Now using node v16.13.1 (64-bit)
C:\Users\Administrator>nvm list
18.6.0
16.16.0
16.15.1
* 16.13.1 (Currently using 64-bit executable)
14.19.3
C:\Users\Administrator>node -v
v16.13.1
C:\Users\Administrator>npm -v
8.1.2