windows 配置Node环境

1. 下载 node 管理工具

nvm-windows

2. 安装完成,验证

3. 安装 node 最新版本,此时是 13.6.0

1
nvm install latest

4. 使用该版本 nvm use 13.6.0

5. 配置 npm 淘宝镜像源

1
2
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global

查看相关配置

1
npm config ls -l

image.png

6. 出现问题

6.1 windows上安装nvm后选择node版本出现exit status 1…

问题:nvm install x.x.x 可以成功,但无法切换和使用

1
2
3
4
5
6
nvm ls
8.9.1
==============================
nvm use 8.9.1
exit status 1: 'D:\Program' ▒▒▒▒▒ڲ▒▒▒▒ⲿ▒▒▒Ҳ▒▒▒ǿ▒▒▒▒еij▒▒▒
▒▒▒▒▒▒▒▒▒ļ▒▒▒

原因:我把 nvm 安装到了有空格的路径上(D:\Program Files),导致切换失败

解决:把 nvm 卸载重装到没有空格的路径上(例如:D:\nvm),即可解决问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
nvm ls
8.9.1
==============================
nvm use 8.9.1
Now using node v8.9.1 (64-bit)
==============================
nvm ls
* 8.9.1 (Currently using 64-bit executable)
==============================
node -v
v8.9.1
==============================
npm -v
5.5.1

原文

错误参考


https://cuifuan.github.io/2021/07/12/software-install/windows/windows配置Node环境/
作者
cuifuan
发布于
2021年7月12日
许可协议