0

So I'm having a lot of trouble getting my node module command line commands to run correctly.

For example if I try and run gulp I get a

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

So I have tried making my environment variable NODE_PATH

%APPDATA%\npm\node_modules\

%APPDATA%\npm\node_modules

%APPDATA%\npm

but none of these seem to work. The only command I can use to get my gulp to run with is

C:\Users\Aaron\Documents\GitHub\2015fallTeam14>node %NODE_PATH%gulp\bin\gulp
[12:10:32] Using gulpfile ~\Documents\GitHub\2015fallTeam14\gulpfile.js

It would appear that cmd is not running my node with my NODE_PATH variable along with my command, but I do not know how to to fix this

McFrank
  • 152
  • 1
  • 10

2 Answers2

1

You need to set the system PATH variable to tell the command prompt where to find gulp.bat (which npm creates).

This has nothing to do with Node itself.

SLaks
  • 800,742
  • 167
  • 1,811
  • 1,896
  • there is no gulp.bat file. Its a node module and is written in javascript. – McFrank Sep 25 '15 at 16:33
  • @McFrank: Wrong. When you install an executable node module, npm will create a `.bat` (or `.cmd`; I forget which) in AppData that runs the node script. This is the only reason it's possible to run on the command line. – SLaks Sep 25 '15 at 17:20
  • ahh you are right its right there in the %AppData%/npm directory which is why it can run these command. its the .cmd That explains why editing the PATH variable works as it does , but I'm still left wondering why its not using my NODE_PATH System Variable. – McFrank Sep 25 '15 at 17:48
  • This is really strange. I manage to get it working but on a restart – McFrank Sep 26 '15 at 15:38
  • This is really strange. I manage to get the commands working but on a restart, they no longer work. I had to move the %AppData%\npm to the start of the path environment variable to get it working again – McFrank Sep 26 '15 at 15:39
  • Looking at my set command it appears that %APPDATA% variable is not getting filled on restart. Strangely enough the APPDATA is set correctly but inside of my path variable it still appears as %APPDATA%. Im going to try and figure out why this is happening. For it to get filled out correctly I have to open my System Variables, Edit the Path Variable , Save it and then close the menus. On every restart – McFrank Sep 26 '15 at 15:56
  • looks like this may be the fix for the issue I am having https://support.microsoft.com/en-us/kb/2913826 saldy the update has already been applied to my windows 8.1 machine . Guess its time to get in contact with microsoft. – McFrank Sep 26 '15 at 16:13
  • As a workaround, you could insert the actual path to the `AppData` folder (which will never change) directly. Make sure to do that in the user PATH variable, not the system one. – SLaks Sep 27 '15 at 00:39
0

I had add the following

Edit "PATH" environment variable and add %APPDATA%\npm

from https://stackoverflow.com/a/27295145/4249440

Im not sure why this works though. I would like to know how the cmd knows to run node on this file path.

Community
  • 1
  • 1
McFrank
  • 152
  • 1
  • 10