2016-09-19 119 views
1

無論我嘗試了什麼,我都無法將Mac升級到最新版本(當前爲3.10.7)。就下拉最新版本而言,該安裝似乎有效,但最新版本仍停留在3.8.0。以下是我可以提出的所有細節。無法將npm升級到Mac上的最新版本

系統:Mac OS X El Capitan, Version 10.11.6

命令:node -v
結果:v6.6.0

命令:npm -v
結果:3.8.0

命令:npm cache clean
結果:什麼

命令:which npm
結果:Users/wrburgess/.npm-packages/bin/npm

命令:npm install -g [email protected]
結果:

/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/lib ├── [email protected] ├── [email protected] ├── [email protected] ├─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] ├─┬ [email protected] │ └── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├─┬ [email protected] │ └── [email protected] ├─┬ [email protected] │ └─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] └── [email protected]

命令:npm cache clean
結果:什麼

命令:npm -v
結果:3.8.0

任何想法?

+0

你是否在同一個終端執行'npm -v',嘗試關閉它並在另一個新終端上運行它。 – chenkehxx

+0

我確實嘗試了終端重啓而沒有成功 – wrburgess

+0

您最初是如何安裝Node/NPM的?你的'npm'可執行文件('/ Users/wrburgess/.npm-packages')的位置不是標準的(官方安裝程序會將它安裝爲'/ usr/local/bin/npm')。 – robertklep

回答

0

當安裝NPM模塊,全球需要(至少在OS X)使用sudo

所以使用:

sudo npm install npm 

如果你看看在你的終端輸出你會本身的一些錯誤消息上漲如果你不使用sudo

+0

我只是爲自己寫了'/ usr/local'來防止使用'sudo'。 – robertklep

+0

如果你想這樣做,你可以改變目錄的所有權http://apple.stackexchange.com/a/192229 –

+1

嗯,是的,這就是我爲自己寫的; D – robertklep

0

可能您需要在/Users/wrburgess/.npm-packages之後在您的路徑之後添加/Users/wrburgess/.npm-packages/bin

所以,你可以把你的〜/ .bash_profile中

出口PATH = /用戶/ wrburgess/.npm-包:/Users/wrburgess/.npm-packages/bin:〜 /.npm:$PATH