简体   繁体   中英

Installing MEAN Stack: npm -v module.js: 338 throw err; Error: Cannot find module './cache/caching-client.js'

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

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".

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM