Cmder: Can't run npm or any Node Module on Cmder (Windows 7)

Created on 21 Jul 2016  路  8Comments  路  Source: cmderdev/cmder

I simply can't run "npm" or, for instance, "gulp" on my cmder. But I can run it if I manually open the cmd

位 gulp
'gulp' is not recognized as an internal or external command,
operable program or batch file.

If I run npm manually from the Nodejs directory, it works. So I added an alias with alias npm=C:\Progra~1\nodejs\npm.cmd $* and now npm works, but I guess that's not the best solution, since I can't run Node modules.

What I've tried

  • I've tried to add "%APPDATA%\npm\node_modules" and "AppData\Roaming\npm" to both System and User environment variables
  • Restarting the computer
  • Running cmd as admin inside of Cmder
  • Add "%APPDATA%\npm\node_modules" and "AppData\Roaming\npm" to "Cmder's user-startup.cmd" path.

I can run Ruby's gem or Python inside of cmder just fine, but Node just won't work specifically inside of Cmder (but will work on window's native cmd.exe)

Most helpful comment

Just leave those files where they are and edit them. They also get run. I like to use profile.d others dont

In userprofile.cmd: set path=%path%;c:\my_dir

In userprofile.sh set $PATH=$PATH:c:\my_dir
In userprofile.ps1: $env:path="$env:path;c:\my_dir"

All 8 comments

For me, npm runs, but I'm specifically unable to npm install gulp. Running from the standard Windows cmd works just fine.

Downloading the latest version of Cmder from the Github repo fixed it (both npm and gulp, I'm not sure if the last version fixed it or if it was because I reinstalled it)
I also updated npm and reinstalled nodejs.

Editing \cmder\vendor\init.bat and adding %APPDATA%\npm to PATH fixed things to me.

:: Enhance Path
set "PATH=%CMDER_ROOT%\bin;%PATH%;%APPDATA%\npm;%CMDER_ROOT%\"

@bogacg You should not edit \cmder\vendor\init.bat because your changes will be overwritten on update. instead you shoul add a path.cmd/path.sh/pasth.ps1 file to cmder\config\profile.d\ that enhances the path with what you need. These changes will not be overwritten on update.

@daxgames Thanks for the heads up. I was aware that it wont get updated but didn't know better way.

config\user-profile.cmd (and .sh and .ps1) is an example for that I guess. I'll copy that to cmder\config\profile.d\ and edit.

Quick question:

Does set PATH (in my path.cmd under config\profile.d\) overwrites whole line what is in vendor\init.bat or just adds what is not there. I guess it overwrites therefor I'm adding whole thing in cmder\config\profile.d\path.cmd

Just leave those files where they are and edit them. They also get run. I like to use profile.d others dont

In userprofile.cmd: set path=%path%;c:\my_dir

In userprofile.sh set $PATH=$PATH:c:\my_dir
In userprofile.ps1: $env:path="$env:path;c:\my_dir"

Thanks @daxgames that worked perfectly

Just leave those files where they are and edit them. They also get run. I like to use profile.d others dont

In userprofile.cmd: set path=%path%;c:\my_dir

In userprofile.sh set $PATH=$PATH:c:\my_dir
In userprofile.ps1: $env:path="$env:path;c:\my_dir"

Thank you very much! You are totally right! I just add this 'path=%path%;D:\testing_tools\dev\nodejs' in the file 'userprofile.cmd'. Then I can use node in the cmder. Cool!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

isnullxbh picture isnullxbh  路  3Comments

brunowego picture brunowego  路  3Comments

jenisys picture jenisys  路  3Comments

justinmchase picture justinmchase  路  3Comments

danwellman picture danwellman  路  3Comments