curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
使用以上脚本安装出现以下错误:
## Your distribution, identified as "n/a", is not currently supported, please contact NodeSource at https://github.com/nodesource/distributions/issues if you think this is incorrect or would like your distribution to be considered for support
解决方法:
# 下载脚本
wget https://deb.nodesource.com/setup_16.x
下载脚本文件修改脚本DISTRO=$(lsb_release -c -s)为 DISTRO=stable,然后在执行以下命令
sudo chmod +x setup_16.x
sudo ./setup_16.x
sudo apt-get install -y nodejs
配置npm全局配置:
#查看当前配置
npm config ls -l
#修改cache和prefix两个目录的配置
npm config set prefix "/opt/.npm/global/"
npm config set cache "/opt/.npm/cache/"
Official Node.js binary distributions are provided by NodeSource.