Node.js 速查
Node.js 安装、NVM 管理、NPM 包管理常用命令
🔍
Node.js 安装与版本查看
node -v查看 Node.js 版本
npm -v查看 NPM 版本
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -Linux 安装 Node.js 20.x
brew install nodemacOS 通过 Homebrew 安装
NVM 版本管理
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash安装 NVM(Node Version Manager)
nvm install 20安装指定版本 Node.js
nvm use 20切换到指定版本
nvm ls列出已安装的版本
nvm alias default 20设置默认版本
nvm uninstall 18卸载指定版本
NPM 包管理
npm init初始化项目(生成 package.json)
npm install <package>安装依赖包
npm install -g <package>全局安装包
npm uninstall <package>卸载依赖包
npm update更新所有依赖
npm list列出已安装的包
npm outdated检查过期的包