1.设置 nvm 镜像
【nvm】下载
cmd 窗口使用
where nvm
找到 nvm 的安装路径,找到 settings.txt 文件,复制下边两行到改文件并保存
node_mirror: https://npmmirror.com/mirrors/node/
npm_mirror: https://npmmirror.com/mirrors/npm/
2.nvm 的简单使用
1> 安装 node
nvm install 18.20.3
2> 卸载 node
nvm uninstall 18.20.3
3> 使用 node
nvm use 18.20.3
4> 查看已安装 node 列表
nvm ls
3.npm 设置淘宝镜像
常常访问 node-sass 不成功,一并设置
npm config set registry https://registry.npmjs.org/ // 还原成官方镜像
npm config set registry https://registry.npmmirror.com -g // 设置淘宝镜像
npm config get registry // 查看是否设置成功
npm config set sass_binary_site https://registry.npmmirror.com/binary.html?path=node-sass -g
设置 npm 缓存
npm config set prefix "E:/RUNTIME/nvm/node_global"
npm config set cache "E:/RUNTIME/nvm/node_cache"
确保 npm config get prefix 出来的命令,已经加入系统变量(把下面路径加入系统变量)
npm config get prefix // E:/RUNTIME/nvm/node_global
4.使用 npm 安装 yarn 并设置淘宝镜像
npm install -g yarn
yarn config set registry https://registry.npmmirror.com -g
yarn config get registry // 查看是否设置成功
yarn config set sass_binary_site https://registry.npmmirror.com/binary.html?path=node-sass -g
设置 yarn 缓存
yarn config set prefix "E:\RUNTIME\nvm\Yarn\Data"
yarn config set global-folder "E:\RUNTIME\nvm\\Yarn\Data\global"
yarn config set cache-folder "E:\RUNTIME\nvm\\Yarn\Cache"
yarn config set link-folder "E:\RUNTIME\nvm\Yarn\Data\link"
查看 yarn 的缓存是否设置成功
yarn config get prefix // E:\RUNTIME\nvm\Yarn\Data
5.pnpm 配置
npm install -g pnpm
pnpm config set registry https://registry.npmmirror.com -g // 设置淘宝镜像
pnpm config set registry https://registry.npmjs.org/ // 设置为官方镜像
pnpm get registry // 查看是否设置成功
pnpm store prune // 清理缓存
pnpm config set global-bin-dir "E:\RUNTIME\nvm\pnpm-store"
pnpm config set cache-dir "E:\RUNTIME\nvm\pnpm-store\pnpm-cache"
pnpm config set state-dir "E:\RUNTIME\nvm\pnpm-store\pnpm-state"
pnpm config set global-dir "E:\RUNTIME\nvm\pnpm-store\global"
pnpm config set store-dir "E:\RUNTIME\nvm\pnpm-store\.pnpm-store"