Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 917
Gregor Voinov Avatar asked Jun 24 '15 11:06

Gregor Voinov


People also ask

How fix npm module not found?

If there is a package. json already existing in your project folder, then from command line you need to go to your project folder and type npm start. npm install --save grunt // And you need to do for all the node_modules, by replacing the **grunt**. Automatically the dependency will be added to your package.

How do I resolve Cannot find module error using node JS?

To solve the "Cannot find module" error in Node. js, make sure to install the package from the error message if it's a third party package, e.g. npm i somePackage . If you get the error with a local module, make sure to point the node command to a file that exists.


2 Answers

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.

like image 60
eush77 Avatar answered Sep 21 '22 03:09

eush77


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 
like image 20
Sam Quayle Avatar answered Sep 21 '22 03:09

Sam Quayle