''gulp' is not recognized as an internal or external command
I am trying to use Gulp and Node.Js to stream my process for minifying and concatenating CSS/JS files for production.
Here is what I have done.
- I installed Node.Js on my Windows 7 machine.
- Installed Gulp globally using this command
npm install -g gulp
- Then I added a new User variable called
NODE_PATH
set it to%AppData%\npm\node_modules
After closing and re-opening my command line, I tried to run a gulp task from the command line (i.e. gulp css
). But that give me the following error
'gulp' is not recognized as an internal or external command
How can I get this to work?
When I opened the following path using the search bar in windows,
%AppData%\npm\node_modules
I see the following two folders
gulp
gulp-cli
I've tried to add %AppData%\npm\node_modules
to the Path
variable on my system variable, but it did not take it because that variable reached it's max allowed character limit.
I removed couple of paths from my Path
variable and added ;C:\Users\[MyWindowsUserName]\AppData\Roaming\npm\node_modules
but still not working.
I even tried to set the path at run time using this command
PATH=%PATH%;C:\Users\[MyWindowsUserName]\AppData\Roaming\npm\node_modules
then run gulp
and still the same issues.
What am I missing here? What else do I need in order to get this to work?
Solution 1:[1]
I solved the problem by uninstalling NodeJs and gulp then re-installing both again.
To install gulp globally I executed the following command
npm install -g gulp
Solution 2:[2]
I had similar issue when I installed locally initially(w/o -g). I reinstalled with -g (global) and then it worked.
npm install -g gulp
you should run gulp from folder where gulpfile.js
is available.
Solution 3:[3]
Go to My Computer>Properties>Advance System Settings>Environment Variables>
Under the variables of Administrator edit the PATH variable & change its value to "C:\Users\Username\AppData\Roaming\npm"
. Note: The username in the path will be the current Admin user's name that you have logged in with.
Solution 4:[4]
I had the same problem on windows 7. You must edit your path system variable manually.
Go to START -> edit the system environment variables -> Environment variables -> in system part find variables "Path" -> edit -> add new path after ";" to your file gulp.cmd directory some like ';C:\Users\YOURUSERNAME\AppData\Roaming\npm' -> click ok and close these windows -> restart your CLI -> enjoy
Solution 5:[5]
You may need to install the gulp-cli
globally. Uninstall then re-install if you already have it:
npm uninstall -g gulp-cli
npm install -g gulp-cli
Solution 6:[6]
Sorry that was a typo. You can either add node_modules to the end of your user's global path variable, or maybe check the permissions associated with that folder (node _modules). The error doesn't seem like the last case, but I've encountered problems similar to yours. I find the first solution enough for most cases. Just go to environment variables and add the path to node_modules to the last part of your user's path variable. Note I'm saying user and not system.
Just add a semicolon to the end of the variable declaration and add the static path to your node_module folder. ( Ex c:\path\to\node_module)
Alternatively you could:
In your CMD
PATH=%PATH%;C:\\path\to\node_module
EDIT
The last solution will work as long as you don't close your CMD. So, use the first solution for a permanent change.
Solution 7:[7]
In my case, this problem occured because I did npm install
with another system user in my project folder before. Gulp was already installed globally. After deleting folder /node_modules/ in my project, and running npm install
with the current user, it worked.
Solution 8:[8]
You need to make sure, when you run command (install npm -g gulp), it will create install gulp on C:\ directory.
that directory should match with whatver npm path variable set in your java path.
just run path from command prompt, and verify this. if not, change your java class path variable wherever you gulp is instaled.
It should work.
Solution 9:[9]
If you have mysql install in your windows 10 try uninstall every myqsl app from your computer. Its work for me. exactly when i installed the mysql in my computer gulp command and some other commands stop working and then i have tried everything but not nothing worked for me.
Solution 10:[10]
I was having the same exception with node v12.13.1,
Downgraded node to v10.15.3 and it works fine now.
Solution 11:[11]
I just encountered this on Windows 10 and the latest NodeJS (14.15.1). In my case our admins have our profiles and true "home" folder remotely mount onto our work machine(s). Npm wanted to put its cache over on the remote server and that has worked until this release.
I was unaware that npm has a .npmrc
file available. I added one to my actual machine's C:\Users\my-id
folder and it contains:
prefix=C:\Users\my-id\nodejs\npm
cache=c:\Users\my-id\nodejs\npm-cache
I also added these paths to my PATH
environment variable.
I went to the APPDATA
folder on my work machine and the remote "home" server and deleted all the npm related Roaming folders. I deleted the node_modules
folder in my project.
I closed all open windows and reopened them. I brought up a command prompt in my project dir and re init
ed npm and reinstalled the modules I wanted.
After that everything is rolling along.
Solution 12:[12]
The best solution, you can manage the multiple node versions using nvm installer. then, install the required node's version using below command
nvm install version
Use below command as a working node with mentioned version alone
nvm use version
now, you can use any version node without uninstalling previous installed node.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow