npm不起作用,请始终获取此错误->错误:找不到模块“我们还在吗" [英] npm doesn't work, get always this error -> Error: Cannot find module 'are-we-there-yet'
问题描述
我试图用优胜美地在Mac上安装grunt.节点已经安装在最新版本中.如果我在终端中输入"node -v",我会得到v0.12.5行.那挺好的.但是当我想使用npm安装某些东西时,我只会得到一个错误...
i tried to install grunt on a mac with Yosemite. node is already installed in the newest version. if i type "node -v" in the terminal i get the line v0.12.5. thats good. but when i want to install something with npm i get only a error...
我尝试了"sudo npm install -g grunt-cli","sudo npm install npm -g"以及"npm -v",我总是收到此错误...
i tried "sudo npm install -g grunt-cli", "sudo npm install npm -g" and also with "npm -v" i get always this error...
Error: Cannot find module 'are-we-there-yet'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/Cellar/node/0.10.22/lib/node_modules/npm/node_modules/npmlog/log.js:2:16)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
有人知道这是什么问题,或者更好的解决方案?
someone knows what's the problem or better a solution?
推荐答案
您已通过删除某些依赖项破坏了npm
.
You have broken npm
by removing some of its dependencies.
are-we-there-yet
是npmlog
的依赖项,而npmlog
本身是npm
的依赖项,因此您以某种方式删除了它.对于这种情况,通常的简单解决方案是重新安装软件包,但是如果npm
无法运行,则该解决方案将不起作用.幸运的是,npm
tarball预先绑定了依赖项,因此从头开始安装npm
就像打开压缩包一样简单.
are-we-there-yet
is a dependency of npmlog
which is a dependency of npm
itself, and you somehow deleted it. The usual simple solution for such cases is reinstalling a package, but that doesn't work if npm
cannot operate. Fortunately, npm
tarball comes prebundled with dependencies and hence installing npm
from scratch is as simple as unpacking a tarball.
1)转到全局node_modules
目录(如果可以运行,将显示npm root -g
内容):
1) Go to the global node_modules
directory (what would npm root -g
print if you could run it):
$ cd /usr/local/lib/node_modules
2)删除损坏的npm
目录,或将其移动到其他位置(请注意,您可能需要为此和以下步骤提升权限):
2) Remove the broken npm
directory or move it somewhere else (note that you might need to elevate permissions for this and the following steps):
$ mv npm /tmp
3)从注册表中下载新鲜的npm
并解压缩(要安装的替代版本,例如3.10.8
):
3) Download and unpack fresh npm
from the registry (substitute version you want to install, e.g. 3.10.8
):
$ curl -L registry.npmjs.com/npm/-/npm-{VERSION}.tgz | tar xz --transform="s:^package:npm:"
您可以使用以下安装脚本将其中一些操作自动化:
You can automate some of that with this install script:
$ curl -L https://www.npmjs.com/install.sh | sh
此时npm
应该可以再次工作.
At this point npm
should work again.
这篇关于npm不起作用,请始终获取此错误->错误:找不到模块“我们还在吗"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!