ubuntu安装node

3/30/2022 nodeubuntu
apt update
apt upgrade
apt install npm
npm install -g npm
npm install -g n
n xx.xx.xx
hash -r
1
2
3
4
5
6
7

首先是更新服务器的apt,然后安装npm,全局更新npm版本到最新或者指定版本npm install -g npm@xx.xx.xx,之后全局安装n,再用n安装node,我一般都是指定版本 n xx.xx.x,然后hash -r就可以正常使用了