Nodejs NPM启动不工作问题,怎么解决

2024-11-03 05:22:59
推荐回答(1个)
回答1:

升级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!

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 npm@next
$ 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