51 lines
1.1 KiB
Markdown
51 lines
1.1 KiB
Markdown
# 安装Nodejs @windows
|
||
|
||
## 系统路径
|
||
|
||
* 不使用默认路径,指向可读写路径比如"C:\Tools\Nodejs"。
|
||
* 建立两个文件夹:node_cache 和 node_global。
|
||
* 环境变量修改:
|
||
* 用户变量,NODE_HOME,指向"C:\Tools\Nodejs"
|
||
* 系统变量,Path,增加:
|
||
* %NODE_HOME%
|
||
* %NODE_HOME%\node_global
|
||
* %NODE_HOME%\node_cache
|
||
* 用户变量,Path,
|
||
* 删掉,C:\Users\AppDate\Roaming\npm
|
||
* 增加,C:\Tools\Nodejs\node_global
|
||
|
||
* 缓存路径处理:
|
||
|
||
```bash
|
||
|
||
# 查看包的默认存放路径
|
||
npm root -g
|
||
|
||
# 设置缓存npm config set cache
|
||
npm config set cache "C:\Tools\Nodejs\node_cache"
|
||
|
||
# 设置全局模块
|
||
npm config set prefix "C:\Tools\Nodejs\node_global"
|
||
|
||
```
|
||
|
||
## 更换npm源为淘宝镜像
|
||
|
||
```bash
|
||
|
||
# 查看源路径
|
||
npm config get registry
|
||
|
||
# 指向淘宝 https://registry.npm.taobao.org
|
||
npm config set registry https://registry.npm.taobao.org/
|
||
|
||
```
|
||
|
||
* 若淘宝的镜像过时
|
||
|
||
```bash
|
||
npm config set strict-ssl false
|
||
npm install cnpm@7.1.1 -g
|
||
```
|
||
|
||
* 若安装报错,文件夹权限放开"Authenticated Users"为修改。 |