SyntaxError:嘗試全域安裝 npm 時出現意外標識符

SyntaxError:嘗試全域安裝 npm 時出現意外標識符

我遇到了一些麻煩!

當運行以下命令時 subrara@subrara-desktop:~$ sudo npm install npm --global

我得到以下資訊:

/usr/lib/node_modules/npm/bin/npm-cli.js:85
      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:935:3

我已經安裝了node和npm,現在我想更新到npm的最新穩定版本。

作業系統:Ubuntu 14.04 LTS 值得信賴

請建議!

答案1

對我來說更好的方法是透過執行以下命令來完全刪除npm和 the :node

sudo apt-get remove nodejs
sudo apt-get remove npm
sudo apt-get update
which node

並使用nvm節點版本管理重新安裝。要安裝,nvm我遵循此說明。https://gist.github.com/d2s/372b5943bce17b964a79

相關內容