5

I just removed Node and reinstalled it with homebrew. I first installed without npm. Then removed that version and installed node with npm.

The install was successful but now I cannot use NPM.

Anything I try with NPM I get error

module.js:338
    throw err;
    ^

Error: Cannot find module 'are-we-there-yet'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:2:16)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

I absolutely have no idea what to try. No npm command I can try. I tried removing and reinstalling node with homebrew but that doesnt work. Please help

UPDATE

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

But the solution did not work. I did not even have the folder

cd /usr/local/Cellar/node/0.10.22/lib/node_modules

In the lib folder there was no node_modules.

even npm i npm -g did not work.

Community
  • 1
  • 1
Nearpoint
  • 7,202
  • 13
  • 46
  • 74
  • possible duplicate of [npm doesnt work, get always this error -> Error: Cannot find module 'are-we-there-yet'](http://stackoverflow.com/questions/31025048/npm-doesnt-work-get-always-this-error-error-cannot-find-module-are-we-ther) – Mr. Llama Sep 24 '15 at 15:49
  • I got this problem bringing up a Vagrant VM. https://github.com/npm/npm/issues/9668 – Sarah Vessels Oct 03 '15 at 15:59
  • Same problem here, following process on Linux server that worked fine a number of times previously. Any new ideas? – edencorbin Oct 08 '15 at 14:56

7 Answers7

3

Same issue when i install yarn , try:

install yarn

cd /usr/local/lib/node_modules/npm

sudo yarn add are-we-there-yet

it's working fine for me ,hope this helps for u.

cow
  • 398
  • 4
  • 12
2

I was having the same issue, try:

cd /usr/local/lib/node_modules

instead, then:

curl registry.npmjs.com/npm/-/npm-2.12.0.tgz |tar xz --transform="s:^package:npm:"

... and

npm i npm -g
Horse
  • 3,023
  • 5
  • 38
  • 65
0

I got node and NPM working again by removing the homebrew install of node, and then installing directly from node.js website using the installer. This might not be the best answer but it is working for me now.

Nearpoint
  • 7,202
  • 13
  • 46
  • 74
0

Okay I struggled with this for 2+ hours on my toggle tracker and have a solution that worked for me. Note that I am not sure what goes wrong with the install process to result in this error, but various simple methods like sudo apt-get install nodejs, sudo apt-get install npm would then result in this error, I am guessing form incompatible/old package repositories. From a clean install this order of installation resulting in a working node / npm install that I could proceed with is as follows:

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

This is basically updating and then following instructions from: https://github.com/nodesource/distributions

Hope this helps somebody else and doesn't take them 2 hours :')

edencorbin
  • 2,569
  • 5
  • 29
  • 44
0

I have encountered this issue a few times. For those of you that use the package n to manage your installation of node, you can just swap versions of node to fix this issue.

For example, first run

sudo n latest

and then run

sudo n stable

(or return to whatever version to wish to use).

If that doesn't fix it yet, then run

npm install -g npm

This is the easiest to recall approach for fixing the problem, assuming you use n (which I highly recommend to anyone that uses node)

To install n,

npm install -g n

Note, you probably will not be able to install n in order to fix this issue. This solution is only for those that already have n installed.

0

Got this error as well. What worked for me:

  1. Delete /usr/local/lib/node_modules
  2. Reinstall NodeJS: brew reinstall nodejs

Done!

blackleg
  • 351
  • 3
  • 3
0

Removing and reinstalling did not work. But I copied npm folder from C:\Program Files\nodejs\node_modules to 'C:\Users\xxx\AppData\Roaming\npm\node_modules' and worked. where xxx is user name

  • Please provide additional details in your answer. As it's currently written, it's hard to understand your solution. – Community Aug 27 '21 at 05:38