当我尝试使用以下命令安装 through2-map 时:
user1@ubuntu:~/nodetest1$ npm install through2-map
我收到错误消息:
npm ERR! Error: Cannot find module 'request'
npm ERR! at Function.Module._resolveFilename (module.js:331:15)
npm ERR! at Function.Module._load (module.js:273:25)
npm ERR! at Module.require (module.js:357:17)
npm ERR! at require (module.js:373:17)
npm ERR! at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/fetch.js:5:15)
npm ERR! at Module._compile (module.js:449:26)
npm ERR! at Object.Module._extensions..js (module.js:467:10)
npm ERR! at Module.load (module.js:349:32)
npm ERR! at Function.Module._load (module.js:305:12)
npm ERR! at Module.require (module.js:357:17)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b3ddc3de9ef3d4dcdcd4dfd6d4c1dcc6c3c09dd0dcde" rel="noreferrer noopener nofollow">[email protected]</a>>
npm ERR! System Linux 3.8.0-34-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "through2-map"
npm ERR! cwd /home/user1/nodetest1
npm ERR! node -v v0.11.10-pre
npm ERR! npm -v 1.3.15
npm ERR! code MODULE_NOT_FOUND
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/user1/nodetest1/npm-debug.log
npm ERR! not ok code 0
我是 Node 新手,不知道为什么会发生这种情况或如何解决它。请帮忙
更新:npm-debug 文件中的其他消息
user1@ubuntu:~/nodetest1$ cat /home/user1/nodetest1/npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli 'through2-map' ]
2 info using <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e789978aa7d6c9d4c9d6d2" rel="noreferrer noopener nofollow">[email protected]</a>
3 info using <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a14151e1f3a0c4a544b4b544b4a570a081f" rel="noreferrer noopener nofollow">[email protected]</a>
4 error Error: Cannot find module 'request'
4 error at Function.Module._resolveFilename (module.js:331:15)
4 error at Function.Module._load (module.js:273:25)
4 error at Module.require (module.js:357:17)
4 error at require (module.js:373:17)
4 error at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/fetch.js:5:15)
4 error at Module._compile (module.js:449:26)
4 error at Object.Module._extensions..js (module.js:467:10)
4 error at Module.load (module.js:349:32)
4 error at Function.Module._load (module.js:305:12)
4 error at Module.require (module.js:357:17)
5 error If you need help, you may report this log at:
5 error <http://github.com/isaacs/npm/issues>
5 error or email it to:
5 error <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1d736d70305d7a72727a71787a6f72686d6e337e7270" rel="noreferrer noopener nofollow">[email protected]</a>>
6 error System Linux 3.8.0-34-generic
7 error command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "through2-map"
8 error cwd /home/user1/nodetest1
9 error node -v v0.11.10-pre
10 error npm -v 1.3.15
11 error code MODULE_NOT_FOUND
12 verbose exit [ 1, true ]
user1@ubuntu:~/nodetest1$
最佳答案
您从 Node.js 不稳定分支上的最新未发布代码的源代码构建了此代码,然后使用 npm 升级 Node 失败。这可能是一个错误,或者是通过对预发布版本的代码执行异常升级而引入的问题。
除非您需要 0.11.x 中的功能,否则我强烈建议您使用最新的稳定版本 0.10.22。
最新的稳定版本始终显着地显示在 node.js website 上.
如果您想要(或需要)从源代码构建,克隆存储库后,您可以使用
git checkout v0.10.22
在构建之前获取正确的版本。
如果你想切换版本,我还建议使用 Node 版本管理器:
关于linux - 无法安装 through2-map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20435510/