npm与n

npm and n

n

n is a simple to use Node.js version manager for Mac and Linux. Specify the target version to install using a rich syntax, or select from a menu of previously downloaded versions. The versions are installed system-wide or user-wide, and for more targeted use you can run a version directly from the cached downloads.

如果您已经有 npm 然后安装 n

npm install -g n

下载 node 的 lts 版本

n lts

在linux上下载想要的版本的 node

直接用 apt 安装,然后用 n

sudo apt update	
sudo apt install nodejs
#不自带 npm 需要自行安装
sudo apt install npm
# 升级 npm (可选)
sudo npm install npm -g	

使用 n 的操作

sudo npm install n -g
# 下载最新稳定版
sudo n stable
# 下载最新版
sudo n lastest
# 查看已下载的版本
sudo n ls
# 切换 Node 版本
sudo n 18.21.1

参考

https://nodejs.org/en/download/package-manager#n
https://blog.csdn.net/weixin_55719805/article/details/128094550

Licensed under CC BY-NC-SA 4.0
Sow nothing, reap nothing.
Built with Hugo 主题 StackJimmy 设计