Ubuntu 安装最新版本Node.js 与 pm2

2020年6月27日 6360点热度 24人点赞 0条评论

选择使用Ubuntu的一个重要原因是其包管理可直接安装的软件非常广泛,简直万物皆可apt(This APT has Super Cow Powers.?),但值得吐槽的是其软件版本较老,据说都是最稳定的版本(其实有好多BUG不及时修复),通过直接apt安装得到的nodejs 是“nodejs/bionic-updates 8.10.0~dfsg-2ubuntu0.4 i386” ,而官网最新版本(截止当前)是14.4.0 (包含 npm 6.14.5,apt中的版本不包括npm),在https://nodejs.org/zh-cn/download/current/ 可以下载源码编译安装或下载编译好的二进制包,不过似乎有些麻烦,以后升级也要重新过来下载部署或编译,虽然Ubuntu官方源中不再更新,但Node.js还是在更新Debian 系列软件包的:Node.js 官方二进制发行版 由 NodeSource 提供。链接如有变动,可以到NodeSource的github找一找。

Node.js v14.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt-get install -y nodejs

更换为淘宝源:

npm config set registry https://registry.npm.taobao.org/

安装pm2:

npm install -g pm2

jlqwer

这个人很懒,什么都没留下

文章评论