虚拟机上ubuntu系统更新node,npm报错

报错:

/usr/local/lib/node_modules/npm/bin/npm-cli.js:87
let notifier = require('update-notifier')({pkg})
^^^^^^^^
SyntaxError: Unexpected identifier
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3

 

解决办法:

1、把安装的npm删除:

(1)cd /usr/local/lib/node_modules

(2)sudo mv npm/ /tmp/usr_local_lib_node_modules_npm

2、重新安装,更新

  1. sudo npm install -g n
  2.  sudo n stable

参考:https://blog.csdn.net/a549416598/article/details/82112580

 

posted on 2020-07-08 11:07  可乐冒泡泡丶  阅读(637)  评论(0编辑  收藏  举报