4

I'm using cmder on windows: http://bliker.github.io/cmder/

I've installed node.js from nodejs.org.

I can run npm in cmder by running this command:

C:\Program Files\nodejs\npm.cmd

Now how can I create an alias for this so I can just run, for example npm install -g bower?

I tried this:

alias npm="C:\Program Files\nodejs\npm.cmd"

But it reports back:

alias npm="C:\Program Files\nodejs\npm.cmd" Files\nodejs\npm.cmd""] was unexpected at this time.

2 Answers 2

5

If a file name includes spaces, it is necessary to use the 8.3 version of the name, like this:

alias npm=C:\Progra~1\nodejs\npm.cmd $*

You can get the short name by using command: dir /x c:\.

source: https://bountify.co/creating-an-alias-for-npm-using-cmder-in-windows

0
1

You might want to add the folder containing npm to the "Path" system variable.

To do that :

  • Go to "Computer" -> Right click on an empty space -> Properties -> Click "Advanced system parameters" which is located on the left panel

  • A new window should have opened -> Select "Advanced system parameters" tab -> Click on "Environment variables"

  • Then select the "Path" under "System variables" and click on modify.

  • You should have something like :

C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\wamp\bin\php\php5.5.12;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\GNU\GnuPG\pub

  • At the end, just add ";PATH_TO_NPM" (Don't forget the ";" at the beginning"

  • Reboot your computer and it should be working.

2
  • 2
    You don't need to reboot your computer. To see the changes in your shell, simply open up a new instance - the new values will be visible there right away.
    – Oliver
    Nov 10, 2015 at 11:42
  • 1
    just need to reboot the terminal
    – Aequitas
    Nov 16, 2017 at 22:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .