首先运行如下命令查看当前本地安装的nodejs的版本号
node -v
1. First, clear the npm cache
npm cache clean -f
2. Install n, Node’s version manager
npm install -g n
3. With the n module installed, you can use it to
- Install the latest stable version:
n stable
- Install the latest release:
n latest
- Install a specific version:
n [version.number]
例如:n 14.15.0 安装node的14.15.0版本
补充:nodejs升级之后通过命令npm模块版本也会更新,它是包含在nodejs安装包里面的资源管理模块。