gulp command not found

2020-02-01 23:26发布

问题:

Windows 10 pro x64

I ran the following commands

npm install --global gulp-cli
npm init

Then I changed directory to my project:

npm install --save-dev gulp

then tried to run gulp and got

-bash: gulp: command not found

my package.json file reads

{
 "name": "riad-kilani_v4-child",
  "version": "1.0.0",
  "description": "",
  "main": "gulpfile.js",
  "dependencies": {
    "gulp-cli": "^1.2.2"
  },
  "devDependencies": {
    "gulp": "^3.9.1",
    "gulp-sass": "^2.3.2"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Any ideas on whats going on here?

回答1:

I had got into the same issue. Even after npm install gulp -g and npm install bower -g, both gulp and bower showed the error.

Here is the thing to remember. 1. gulp and bower command does not run in root (sudo). Switch back to the system user and the run it 2. Make sure the folder where you are running gulp has the user permission. else the permission will be denied

Hope this works for you



回答2:

I solved the problem creating an alias in ~/.bashrc like this:

alias gulp="node /home/deploy/app/node_modules/gulp/bin/gulp.js"

Just put the alias in the end of the .bashrc file, then run:

source ~/.bashrc

Test with:

gulp -v

You should see something like this:

[15:46:39] CLI version 3.9.1
[15:46:39] Local version 3.9.1


回答3:

I'm using Ubuntu and found the error of -bash: gulp: command not found, too. But it became work after npm install gulp -g



回答4:

So I ran into this issue as well and none of the top answers were helping. Everything was installed, uninstalled, restarted, installed globally, etc., etc.... and still got the gulp command not found error. So I opened the package.json file and put in the following after the name field:

  "scripts": {
"start": "gulp"
},

And then I ran npm start in git bash.

Everything ran correctly, I got my dev view in my browser @ localhost and all was right with the world.

Hope this helps!



回答5:

I managed to fix this problem using simple 3 commands found from https://gulpjs.com/

npm install gulp-cli -g

npm install gulp -D

npx -p touch nodetouch gulpfile.js

Hope it helps someone else.

ps: it is not mandatory to use the 3rd command in order to fix the problem.



回答6:

On MacOS Sierra v10.12.6, the following global install with sudo worked for me.

sudo npm install gulp -g



回答7:

For anyone else who runs into this just run npm install and npm update.

I ran npm rm --global gulp to clear out any version conflicts and then ran npm install --global gulp-cli. This did a clean install of gulp and it works flawlessly now.



标签: npm gulp cygwin