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

node.jsMacosInstallationNpm

node.js Problem Overview


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?

node.js Solutions


Solution 1 - node.js

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

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

Solution 3 - node.js

Even i had same issue, Easiest way to solve below steps worked for me.

  1. uninstall Nodejs.

  2. Go to C:/Users/<user_name>/AppData/Roaming.

  3. Delete npm directory.

  4. Reinstall Nodejs (latest v6.11.3,includes npm 3.10.10).

  5. Done Now try to check (npm -v) will be working fine.

Solution 4 - node.js

What eush77 said, but if you're on Windows:

download the latest package from https://nodejs.org/download/release/npm/

unpack, and replace the "npm" directory in the nodejs node-modules directory (by default C:\Program Files\nodejs\node_modules)

Solution 5 - node.js

I have been trying feverishly to get to the latest version of node and npm on my centos 7 machine.

Unfortunately, I have been plagued with this error for near a week now. And I have finally found a solution that works.

If your npm is currently broken, It is easiest just to install a working version again.

I installed from code. Assuming git is installed, the following commands will accomplish that goal

cd ~
git clone https://github.com/nodejs/node.git nodejs_code
cd nodejs_code
./configure
make
make install

After you have installed a fresh copy of npm and node, which by the way is not the stable version (Instead its bleeding edge right from source).

Installed version of node at time of writing this was 5.0.0-pre which is too new for me, and npm was version 2.14.4 which is too old for me.

To get to the latest version on node, I will install the 'n' package using npm. Using n, I will install the latest version of node.

npm install -g n
n stable

In the case of the root user, (which I use to install global packages) I needed to add the following line to my ~/.bashrc file, which will allow the root user to access the commands in /usr/local/bin commands. (You may not need this step)

export PATH=/usr/local/bin:$PATH

At this point my version of node is 4.0.0 which is the latest stable version of node.

now to update npm, which was the most annoying thing ever.

Updating directly to the newest version always resulted in "are-we-there-yet" which I could only surmise as "NO, and Quit Asking or I will turn this node around"

Instead I have found that installing through version 3.3.3 first would solve this problem.

npm install -g npm@3.3.3

now version 3.3.3 is installed and works without the "are-we-there-yet" error.

Thank goodness. Keep your arms inside and you seatbelts fastened kids, because we are almost there.....

npm install -g npm

and with that final command, I was able to use the latest version of npm, with the latest stable version of node. Which at the time of writing this is 3.3.5

From here on out, my commands are as follows.

n stable
npm install -g npm

each time I run these from here on out, I am granted undisturbed npm trips without the kids complaining in the back.

Note

As I am moderating a number of servers, none of which come with node by default, I find myself having to perform this task over and over..

Therefore I have taken it upon myself to turn these instructions into a script.

Enjoy:

importnode.sh

#!/bin/bash

cd ~
git clone https://github.com/nodejs/node.git nodejs_code
cd nodejs_code
git reset --hard
git pull origin master
./configure
make
make install

if [[ `cat ~/.bashrc |grep -E "PATH.*/usr/local/bin:.*"` ]];
then
    echo "Already Done";
else
    echo "export PATH=/usr/local/bin:\$PATH" >> ~/.bashrc;
    export PATH=/usr/local/bin:$PATH;
fi;

npm install -g n
n stable

npm install -g [email protected]

npm install -g npm

The only thing left to do after putting this into nodeimport.sh is to make it executable and execute it.

$ chmod +x importnode.sh
$ ./importnode.sh

Wait a while, and all is installed.

Solution 6 - node.js

I followed the instructions above (what eush77 said) to remove the npm folder in the node_modules folder. But there remains the broken link resulting in this error message.

/usr/local/bin/npm: No such file or directory

so remove the broken link:

rm /usr/local/bin/npm

and then make it point to the right place like this:

sudo ln -s /usr/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm

Solution 7 - node.js

You could also reinstall node from https://nodejs.org/en/download/current/

Solution 8 - node.js

For me this had to do with installations being corrupted and perhaps ubuntu repositories not being compatible or the most recent. The following resulted in a working npm/node install:

sudo curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - sudo apt-get install -y nodejs

https://github.com/nodesource/distributions

Solution 9 - node.js

I got it reset by using the official installer package found: https://nodejs.org/en/

Playing around with n and nvm eventually corrupted the node_modules packages for me by providing packages incompatible with current Node version.

I suspect it'd work for other environments as it couples both Node AND npm install.

Solution 10 - node.js

For me, I had to remove my project's node_modules folder. I then cleaned the cache just in case and did a fresh npm i and it was able to do the node-sass post-install and not error at are-we-there-yet missing.

If moving global node_modules doesn't work for you like in the solutions above try:

  1. Remove your project's local node_modules
  • In your project's root: rm -rf node_moduldes
  1. npm cache clean -f
  2. npm i

Solution 11 - node.js

I just had the same problem while deploying the project on local server when I was invoking the yarn dev command.

After going through all the blogs, articles and stuff I got it working just by simple this 2 commands.

  1. npm list check at what version it is pointing right now. For me, when I was getting this error. It was pointing to the system.

  2. I just used the nvm use v{VERSION} e.g. nvm use v10.5.0 (for me) and it got working. All the errors went away and the project got deployed successfully while invoking the yarn dev. Try this before doing anything else. I highly recommend.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGregor VoinovView Question on Stackoverflow
Solution 1 - node.jseush77View Answer on Stackoverflow
Solution 2 - node.jsSam QuayleView Answer on Stackoverflow
Solution 3 - node.jssanthoshView Answer on Stackoverflow
Solution 4 - node.jsuser2656961View Answer on Stackoverflow
Solution 5 - node.jsThe Lazy CoderView Answer on Stackoverflow
Solution 6 - node.jsWalker RoweView Answer on Stackoverflow
Solution 7 - node.jsocolotView Answer on Stackoverflow
Solution 8 - node.jsedencorbinView Answer on Stackoverflow
Solution 9 - node.jsYann VRView Answer on Stackoverflow
Solution 10 - node.jsMikeumusView Answer on Stackoverflow
Solution 11 - node.jsSupRemoView Answer on Stackoverflow