ubuntu安装node

操作步骤

apt update
apt upgrade
apt install npm
npm install -g npm
npm install -g n
n xx.xx.xx
hash -r

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