1

I install nodejs, npm, then use this command to install bower:

npm install -g bower
npm bower -v 
2.15.5
node -v 
v4.4.5

However in my Git Bash, I can't run bower:

$ bower
module.js:327
    throw err;
    ^

Error: Cannot find module 'C:\Program Files\Git\node_modules\bower\bin\bower'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3

Things I have tried:

  • I have tried the solution from here by adding to PATH, but still no help. Any idea why it happened and how to solve it ?

  • Install bower locally: npm install bower.

Community
  • 1
  • 1
Dio Phung
  • 5,944
  • 5
  • 37
  • 55
  • Just to clarify, all commands like `npm install -g bower` - have you run them in `git bash`? – Ivan Nov 28 '16 at 05:19
  • Try removing `C:\Program Files\Git\node_modules` - I don't think you intended to install files there, and it may be interfering with the global installation. – Aurora0001 Nov 28 '16 at 17:54
  • @Ivan : yep I ran them in `git bash`. – Dio Phung Nov 29 '16 at 06:47
  • @Aurora0001 : exactly, `bower` should be installed under `%APPDATA%\`, I removed those files and still can't get bower to be recognizable. – Dio Phung Nov 29 '16 at 06:48
  • What does `npm config get prefix` output? – Aurora0001 Nov 29 '16 at 16:46
  • @Aurora0001 : it's `C:\Users\Dio\AppData\Roaming\npm` . – Dio Phung Nov 29 '16 at 18:34
  • That appears to be right. Open that up in Windows Explorer and verify that Bower is there - if not, we know that the global install didn't work at all. – Aurora0001 Nov 29 '16 at 18:54
  • `bower` and `bower.cmd` are there. I even had `%APPDATA%` in my PATH and yet it still showed error. After digging up some more, I notice my Nodejs was quite old (v4.4.5) so I went ahead and upgrade to v6.9.1 LTS. The problem is gone ! Not the best solution but it works for me. – Dio Phung Nov 29 '16 at 22:51

0 Answers0