进入node官网下载安装包
安装选择下面选项
在 D盘新建一个目录,用来存放 npm 或 yarn 的 cache 和 依赖包文件
D:\node_package\npm
D:\node_package\npm_cache
D:\node_package\yarn
D:\node_package\yarn_cache
更改npm 和 yarn 的配置
# npm
npm config set prefix "D:\node_package\npm"
npm config set cache "D:\node_package\npm_cache"
npm config set registry https://registry.npm.taobao.org/
# yarn
yarn config set global-folder "D:\node_package\yarn"
yarn config set cache-folder "D:\node_package\yarn_cache"
yarn config set registry https://registry.npm.taobao.org/
查看配置
# npm
npm config list
# yarn
yarn config list
为了让安装的包,能在控制台使用,需要配置 Path 环境变量