6

Any command I'm try to run with npm I get:

module.js:340
    throw err;
          ^
Error: Cannot find module 'balanced-match'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/glob/node_modules/minimatch/ node_modules/brace-expansion/index.js:2:16)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

Including when I try to npm install -g balanced-match

Matheus Lima
  • 2,103
  • 3
  • 31
  • 49
  • Possible duplicate of [NPM global install "cannot find module"](http://stackoverflow.com/questions/12594541/npm-global-install-cannot-find-module) – thomaux Jan 20 '16 at 13:22
  • No duplication here, I'm not trying to run the package and getting the error, I'm trying to install the package. – Matheus Lima Jan 20 '16 at 13:26
  • Root cause could be the same? Is your NODE_PATH correct? – thomaux Jan 20 '16 at 13:29
  • Which node and npm version do you use and how did you install, nvm or something else? – Zlatko Jan 20 '16 at 13:42

2 Answers2

0

I know this is very old, and I hope that you found your answer, but for future questors:

I saw this issue recently when I tried to use npm after upgrading node to a newer version with n.

If you recently moved to a newer version of node, and you experience the error mentioned above, you may fix it by installing the latest version of npm. As this may not be possible, because npm is used to update itself, and npm is obviously not working:

  1. Downgrade back to an earlier version of node where your copy of npm worked.
  2. Update npm: sudo npm install npm@latest -g
  3. Upgrade back to the version of node you were using before.

If that doesn't work, or you think it will be easier anyway, you may have to reinstall npm from binary.

If you haven't changed versions of node recently, you may need to reinstall node, or at least npm, from their websites.

user4815162342
  • 2,058
  • 3
  • 18
  • 23
  • Saddly this didn't work for me :/ I just installed package locally, but that ignores the problem – Kevin Danikowski May 04 '18 at 20:16
  • I should have specified that my answer "worked for me". But, when you say this didn't work, are you saying that even after reinstalling node and npm (as mentioned in the last paragraph), it still didn't work? – user4815162342 Jun 06 '18 at 20:50
  • yes I meant after doing what you said, I only mentioned my comment for those who didn't think to just install it locally and ignore the problem – Kevin Danikowski Jun 06 '18 at 21:33
-1

I can suggest you the following link which suggest how to install

npm balanced-match

https://www.npmjs.com/package/balanced-match

or download from

github.com/juliangruber/balanced-match

Mohit Gupta
  • 203
  • 2
  • 12