1. 程式人生 > >node 升級

node 升級

升級Node後,執行npm install出現以下錯誤:

DLCM50893462A:user-dashboard i318043$ npm install
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/5.6.0/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v7.4.0
npm ERR! npm v4.0.5
npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module 'internal/fs'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR! /Users/i318043/z/react/user-dashboard/npm-debug.log
根據“https://github.com/nodejs/node/issues/9377”其中一個回覆的描述,大意為需要先為NodeJS,然後安裝npm,然後重新升級NodeJS

This worked for me on a Mac:

$ sudo n 6.9.1
$ sudo npm -g install [email protected]
$ sudo n stable

$ node -v
v7.2.1
$ npm -v
3.10.10

下面是更新最新Node的方法,不需要像上面那樣指定NodeJS的版本號。

https://davidwalsh.name/upgrade-nodejs

sudo npm cache clean -f
sudo npm install -g n
sudo n stable