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?
Solution 1:
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.
Solution 2:
Go to the global node_modules directory (npm root -g if you don't know)
$ cd /usr/local/lib/node_modules
curl -L https://www.npmjs.com/install.sh | sh