NodeJS npm安装失败,并显示“找不到模块'glob'"

6tdlim6h  于 2022-11-29  发布在  Node.js
关注(0)|答案(2)|浏览(954)

以下是控制台上的输出:

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,直到昨天一切都很好。
有人能给我指出解决这个问题的正确方向吗?

deikduxw

deikduxw1#

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

nhhxz33t

nhhxz33t2#

在我的例子中,我的Node.js是通过.pkg文件安装的(在macOS上)。并试图重新安装npm,但失败了。
我解决了这个问题,卸载节点完全遵循这个要点:https://gist.github.com/TonyMtz/d75101d9bdf764c890ef

相关问题