Node 版本管理
Node 版本管理
- 全局安装 Node 版本管理工具 n
1$ npm install -g n
- 安装 Node 最新版
1$ n latest
- 安装 Node 最新稳定版
1$ n stable
- 安装指定的 Node 版本
1$ n 10.13.0
- 删除已安装的 Node 版本
1$ n rm 10.13.0
- 切换 Node 版本
1$ n 10.13.0
- 以指定的 Node 版本来执行脚本
1$ n use 10.13.0 test.js
- 查看已安装 Node 版本
1$ n ls
- 查看服务器上所有可用的 Node 版本
1$ n ls-remote --all
npm 镜像源切换
-
查看当前 npm 镜像源
1$ npm config list 2------------------------- 3; "user" config from /Users/caigou/.npmrc 4 5registry = "https://registry.npm.taobao.org" 6 7; node bin location = /usr/local/bin/node 8; node version = v20.11.0 9; npm local prefix = /Users/caigou/Developer/artwebsite 10; npm version = 10.2.4 11; cwd = /Users/caigou/Developer/artwebsite 12; HOME = /Users/caigou 13; Run `npm config ls -l` to show all defaults.
-
清空缓存
1$ npm cache clean --force
-
修改 npm 镜像源
1$ npm config set registry https://registry.npmmirror.com 2---------------------------------- 3// https://registry.npmmirror.com 淘宝新的镜像源 4// https://registry.npmjs.org npm 官方源