nodejs 版本管理

发布时间: 更新时间: 总字数:188 阅读时间:1m 作者:IP:上海 网址
专栏文章
  1. PM2: Node.js 进程管理
  2. Bun: 运行JavaScript 和TypeScript 应用程序的集成工具包
  3. Yarn JavaScript 包管理器介绍
  4. nodejs 版本管理(当前)
  5. NPM Registry Proxy 配置
  6. npm 常用命令
  7. 使用 forever 运行 nodejs 应用

python 我们使用 env 来管理不同版本之间的切换。nodejs 是否有类似的切换版本的方法哪?本文提供一种在 mac 上快速切换 nodejs 版本的方法。

n

npm i -g n
sudo n v11
node --version

nvm

nvm(Node Version Manager) node 版本管理工具

安装

  • Linux
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
  • windows

https://github.com/coreybutler/nvm-windows/releases

使用

source ~/.bashrc
# 查看支持的版本,访问 https://nodejs.org/dist/index.json 获取的列表
nvm list available

#安装
nvm install 24

# 切换
nvm use 24

# 设置默认版本
nvm alias default 24

其他

类似的工具:

  • volta 无忧无虑的JavaScript工具管理器
# install Volta
curl https://get.volta.sh | bash

# install Node
volta install node

volta install node@16

# start using Node
node