Thursday, February 19, 2015

How to run npm installed components from commandline in Windows?

When you are working with windows and nodejs, then you might face this problem, whatever npn packages you install might not be accessible through commandline. By this I mean, is that, suppose you did:

npm install -g bower

And then executed :

bower install

Windows might give you an error that 'bower' is unrecognized.
A solution to the problem is to add npm global repository to your system path. To do so execute

npm config get prefix

To get the npm global repository path. Copy this path and follow following steps to add to windows path:

  1. On your computer, select Start->Settings->Control Panel->System:
  2. A "System Properties" dialog box will appear. Click it's Advanced tab:
  3. Click the Environment variables button:
  4. An Environment Variables dialog box will appear. In the System variables section, scroll down until you find the PATH variable. Select this variable:
  5. Click the Edit button to edit the value of this variable.
  6. At the end of the "Variable value:" box, add
            ;
    
  7. Click the OK button in each dialog box, until they have all disappeared.

Once, added you would have to restart command prompt and Hola! everythings works :)