2

I think I have installed node.js before but never used homebrew to do it. Today I tried to do a walkthrough of an application but got stuck at the very beginning. I am fairly new to programming so I am utterly confused as to why I can't get this to work.

I have tried a lot of things but can't seem to find the answer.

These are the commands I run in order to install the MEAN stack:

  1. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" (succesful no errors)
  2. brew install node (succesfull no errors)
  3. I check if node has installed properly by typing: node -v v0.12.4
  4. I then check if npm is installed properly by typing: npm -v

Here is the error message:

module.js:338
    throw err;
          ^
Error: Cannot find module './cache/caching-client.js'
    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 /usr/local/lib/node_modules/npm/lib/npm.js:22:24
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/npm.js:466:3)
    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)

I have installed node in a different way other than using Homebrew and maybe that is messing things up. Please let me know your thoughts.

What I have tried to do so far is uninstall node and reinstall it using this process: https://gist.github.com/DanHerbert/9520689

Brent Washburne
  • 12,904
  • 4
  • 60
  • 82
  • Maybe your $NODE_PATH is empty, please follow this [link](http://stackoverflow.com/questions/12594541/npm-global-install-cannot-find-module) – Mariusz Beltowski Jun 19 '15 at 23:25

2 Answers2

1

Maybe you've already fixed, but the answer might serve others.

I tried what is in the post that Mario linked to in his comment, but it didn't work. It just so happens that my npm is installed at /Users/USERNAME/.node/bin/, so I added the following line in my .bash_profile file: export PATH="$HOME/.node/bin:$PATH".

Som
  • 307
  • 3
  • 11
0

In my case it was caused by me installing node with root and later with brew (without root).

As a result brew was not able to override the old npm files upon upgrading.

Manually removing the old node installation worked for me.

Chen Xing
  • 1,665
  • 2
  • 13
  • 13