npm安装失败并显示“无法找到模块'glob'”

时间:2014-09-23 01:09:59

标签: node.js macos npm glob node-modules

以下是控制台上的输出:

floydpink@MBP mean-app (master) $ npm install
npm ERR! Darwin 13.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.10.32
npm ERR! npm  v2.0.0
npm ERR! code MODULE_NOT_FOUND

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

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/floydpink/Source/swara-server/mean-app/npm-debug.log
floydpink@MBP mean-app (master) $ 

和npm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'install' ]
2 info using npm@2.0.0
3 info using node@v0.10.32
4 verbose node symlink /usr/local/bin/node
5 verbose stack Error: Cannot find module 'glob'
5 verbose stack     at Function.Module._resolveFilename (module.js:338:15)
5 verbose stack     at Function.Module._load (module.js:280:25)
5 verbose stack     at Module.require (module.js:364:17)
5 verbose stack     at require (module.js:380:17)
5 verbose stack     at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/completion/file-completion.js:5:12)
5 verbose stack     at Module._compile (module.js:456:26)
5 verbose stack     at Object.Module._extensions..js (module.js:474:10)
5 verbose stack     at Module.load (module.js:356:32)
5 verbose stack     at Function.Module._load (module.js:312:12)
5 verbose stack     at Module.require (module.js:364:17)
6 verbose cwd /Users/floydpink/Source/swara-server/mean-app
7 error Darwin 13.4.0
8 error argv "node" "/usr/local/bin/npm" "install"
9 error node v0.10.32
10 error npm  v2.0.0
11 error code MODULE_NOT_FOUND
12 error Cannot find module 'glob'
13 error If you need help, you may report this error at:
13 error     <http://github.com/npm/npm/issues>
14 verbose exit [ 1, true ]

几天前我升级到了这个版本的nodejs和npm,直到昨天还没事。

有人能指出我正确的方向来解决这个问题吗?

2 个答案:

答案 0 :(得分:0)

我遇到了确切的问题。但我没有在我的Ubuntu Amazon EC2实例上酿造(我不想安装它)。我使用sudo npm uninstall npm –g卸载了npm,然后在NPM目录中再次运行make install命令以重新编译npm并修复了该问题。

答案 1 :(得分:0)

就我而言,我的Node.js是由.pkg文件安装的(在macOS上)。并尝试重新安装npm但失败了。

我通过卸载节点完全按照这个要点解决了这个问题:https://gist.github.com/TonyMtz/d75101d9bdf764c890ef