本文最后更新于 2025年8月14日 星期四 10:51
下载与安装
下载 nvm
Windows 前往 https://github.com/coreybutler/nvm-windows/releases 下载
nvm-setup.exe,并安装。
Linux 和 macOS 前往
https://github.com/nvm-sh/nvm#installing-and-updating
下载并安装,具体指令如下:
1 2 3
| curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
|
使用 nvm 安装 Node.js
1 2
| nvm install latest nvm install stable
|
使用
1 2 3 4 5 6 7 8 9 10 11 12 13
| nvm ls
nvm use 24.4.1
nvm -v node -v npm -v
npm install -g npm@latest
|
全局包管理
1 2 3 4 5 6 7 8 9 10 11
| npm ls -g --depth=0
npm root -g
npm outdated -g
npm uninstall -g 包名
|
更新包
以 Hexo 为例
1 2 3 4 5 6
| npm install -g hexo-cli@latest
npm update npm install --save hexo@latest
|
配置 proxy
1 2 3 4 5 6 7 8 9 10
| npm config get proxy npm config get https-proxy
npm config set proxy http://localhost:7890 npm config set https-proxy http://localhost:7890
set HTTP_PROXY=http://localhost:7890 set HTTPS_PROXY=http://localhost:7890
|
如果不用代理,可以制定镜像源。默认镜像为
https://registry.npmjs.org/,可以更改为淘宝镜像以加快下载速度。
1 2 3
| npm config set registry https://registry.npmmirror.com/ npm config get registry npm config rm registry
|