Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
460 views
in Technique[技术] by (71.8m points)

node.js - npm doesn't work, get always this error -> Error: Cannot find module 'are-we-there-yet'

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...

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have broken npm by removing some of its dependencies.

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) 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) 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) 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

At this point npm should work again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...