错误:
/usr/local/lib/node_modules/npm/bin/npm-cli.js:85
let notifier = require('update-notifier')({pkg})
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
解决办法:
1.移除错误的node_modules
cd /usr/local/lib/
rm node_modules/ -rf
2.卸载nodejs:
sudo apt-get autoremove nodejs
3.更新源,准备重新安装:
sudo apt-get update
sudo apt-get install -y python-software-properties software-properties-common
sudo add-apt-repository ppa:chris-lea/node.j
sudo apt-get update
4.安装nodejs:
sudo apt-get install nodejs
sudo apt install nodejs-legacy
sudo apt install npm
5.更新npm的包镜像源,方便快速下载
sudo npm config set registry https://registry.npm.taobao.org
sudo npm config list
6.全局安装n管理器(用于管理nodejs版本)
sudo npm install n -g
7.安装最新的nodejs(stable版本)
sudo n stable
sudo node -v