npm init错误,重新安装了node也不行

cfanbo
  • 658

mac环境,前段时间还正常,后来安装了一些东西就不行了,使用 brew安装,推卸重新安装也不行,安装任何包都提示这个错误

➜ demo$ npm init
module.js:545

throw err;
^

Error: Cannot find module '../lib/utils/unsupported.js'

at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)

➜ demo# npm i yarn
module.js:545

throw err;
^

Error: Cannot find module '../lib/utils/unsupported.js'

at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
回复
阅读 5.5k
1 个回答

将整个目录 /usr/local/lib/node_modules删除掉,再重新卸载安装解决了。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏