安装最新版本的Nodejs
==================
1 | sudo apt-get install npm |
ref: https://segmentfault.com/a/1190000007542620
如果遇到以下问题1
2
3
4
5
6
7
8
9
10
11
12
13
14
15sudo npm install -g n
/usr/local/lib/node_modules/npm/bin/npm-cli.js:79
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
则只需要删除安装的npm1
2cd /usr/local/lib/node_modules
mv npm/ /tmp/usr_local_lib_node_modules_npm
然后重新执行1
2sudo npm install -g n
sudo n stable