npm找不到模块 [英] npm cannot find module

查看:419
本文介绍了npm找不到模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经遍历Google和StackOverflow,查看了与类似问题相关的各种线程,但是到目前为止,没有任何效果.我的问题是npm似乎安装不正确...或者某些东西,老实说,我不知道:Node和npm是我用来支持在另一台计算机上工作的Sage Wordpress主题构建的依赖项.

I've been all over Google and StackOverflow, viewing the various threads related to similar issues, but so far nothing has worked. My problem is that npm seems to be installing improperly...or something, I honestly have no idea: Node and npm are a dependency I use to support the Sage Wordpress theme buildout I'm working on on a different machine.

所以问题在于,卸载Node(为了安全起见)并重新安装之后,Node似乎运行良好. node -v返回v5.1.0.伟大的. npm应该随它一起安装,但是当我运行npm -v时,我得到以下错误:

So the issue is that after uninstalling Node (to be safe), and reinstalling, Node seems to be working fine. node -v returns v5.1.0. Great. npm should be installed with it, but when I run npm -v I get the following lovely bit of error:

    $ npm
    module.js:340
        throw err;
        ^

    Error: Cannot find module 'readable-stream'
        at Function.Module._resolveFilename (module.js:338:15)
        at Function.Module._load (module.js:289:25)
        at Module.require (module.js:366:17)
        at require (module.js:385:17)
        at Object.<anonymous>                 (/Users/Daniel/.nvm/versions/node/v5.1.0/lib/node_modules/npm/node_modules/        npmlog/node_modules/are-we-there-yet/index.js:2:14)
        at Module._compile (module.js:425:26)
        at Object.Module._extensions..js (module.js:432:10)
        at Module.load (module.js:356:32)
        at Function.Module._load (module.js:313:12)
        at Module.require (module.js:366:17)

运行任何npm命令(甚至只是npm)都会给我这个错误,因此,正如其他解决方案所建议的那样,我不能简单地运行npm install readable-stream.我还经历了各种解决方案(删除node_modules文件夹,通过brew安装,通过不带npm的brew安装,以及其他几种解决方案),但是似乎没有一个起作用.

Running any npm command (even just npm) gives me this error, so as suggested in other solutions, I cannot simply run npm install readable-stream. I have also gone through various solutions (removing the node_modules folder, installing via brew, installing via brew without npm, and several others), but none seem to be working.

任何想法都将不胜感激.

Any thoughts would be much appreciated.

推荐答案

如果您在使用NPM时遇到问题,并且想要在UNIX上重新安装,我发现这是最简单的解决方案:

If you're having problems with NPM and you want to reinstall on UNIX I found this to be the easiest solution:

curl -L https://npmjs.org/install.sh | sudo sh

这将重新安装NPM并进行设置以使用最新的NPM版本.这几乎总能解决有关NPM的所有问题.

This will reinstall NPM and get it setup to use the latest NPM Version. This will almost always resolve any issues regarding NPM.

该过程完成后,您应该会收到一条消息,提示It worked.

When the process is complete you should receive a message saying It worked.

这篇关于npm找不到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆