knowledge-vault/sources/references/开发笔记/Nodejs/安装Nodejs.md

51 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 安装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"为修改。