错误:找不到模块'update-notifier'

Joc*_*acx 4 node.js npm npm-install

每次我npm在mac终端上运行时,都会遇到此错误

Mac01:~ qa$ npm
module.js:515
    throw err;
    ^

Error: Cannot find module 'update-notifier'
    at Function.Module._resolveFilename (module.js:513:15)
    at Function.Module._load (module.js:463:25)
    at Module.require (module.js:556:17)
    at require (internal/module.js:11:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:29:19
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
Run Code Online (Sandbox Code Playgroud)

- > http://prntscr.com/h1r3yu

我该怎么解决?

AM_*_*_FM 5

进入这个问题.即使是简单的npm --version轰炸同样的消息也是如此.这引导我对brew卸载,符号链接错误,rm删除文件/ node_modules/npm&/ node,chowning目录进行疯狂追逐 - 你得到了要点.不确定我的brew-failure的根本原因,但它可能与npm作为独立安装安装有关,而node现在包括npm,这导致我的机器上的brew配置地狱.
我建议上面的提示,但如果一切都失败了,对我有用的是通过brew卸载,然后转到https://nodejs.org/en/download站点并重新安装.相信我,我不想离开终端而不使用brew,但在这种情况下,这是唯一对我有用的解决方案.

  • 通过brew:brew uninstall --ignore-dependencies node或卸载节点brew uninstall --force node
  • https://nodejs.org/en/download下载并重新安装.
  • 现在测试以查看错误是否消失了 npm --version