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의 최신 안정 버전으로 업데이트하고 싶습니다.

OS: 우분투 14.04 LTS Trusty

제안해주세요!

답변1

나에게 더 좋은 방법은 다음을 실행하여 npm및 를 완전히 제거하는 것입니다.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

관련 정보