After installation of Gulp: “no command 'gulp' found”

后端 未结 9 2195
悲&欢浪女
悲&欢浪女 2020-11-28 17:45

After installing gulp.js via npm, I receive a no command \'gulp\' found error when running the gulp command from the same directory it was installe

相关标签:
9条回答
  • 2020-11-28 18:23

    if still not resolved try adding this to your package.js scripts

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

    and run npm run gulp it will runt gulp scripts from gulpfile.js

    0 讨论(0)
  • 2020-11-28 18:31

    I solved the issue without reinstalling node using the commands below:

    $ npm uninstall --global gulp gulp-cli
    $ rm /usr/local/share/man/man1/gulp.1
    $ npm install --global gulp-cli
    
    0 讨论(0)
  • 2020-11-28 18:31

    I'm on lubuntu 19.10

    I've used combination of previous answers, and didn't tweak the $PATH.

    1. npm uninstall --global gulp gulp-cli This removes any package if they are already there.
    2. sudo npm install --global gulp-cli Reinstall it as root user.

    If you want to do copy and paste

    npm uninstall --global gulp gulp-cli && sudo npm install --global gulp-cli 
    

    should work

    I guess --global is unnecessary here as it's installed using sudo, but I've used it just in case.

    0 讨论(0)
  • 2020-11-28 18:34

    I actually have the same issue.

    This link is probably my best guess:

    nodejs vs node on ubuntu 12.04

    I did that to resolve my problem:

    sudo apt-get --purge remove node 
    sudo apt-get --purge remove nodejs 
    sudo apt-get install nodejs
    sudo ln -s /usr/bin/nodejs /usr/bin/node
    
    0 讨论(0)
  • 2020-11-28 18:36

    That's perfectly normal. If you want gulp-cli available on the command line, you need to install it globally.

    npm install --global gulp-cli
    

    See the install instruction.

    Also, node_modules/.bin/ isn't in your $PATH. But it is automatically added by npm when running npm scripts (see this blog post for reference).

    So you could add scripts to your package.json file:

    {
        "name": "your-app",
        "version": "0.0.1",
        "scripts": {
            "gulp": "gulp",
            "minify": "gulp minify"
        }
    }
    

    You could then run npm run gulp or npm run minify to launch gulp tasks.

    0 讨论(0)
  • 2020-11-28 18:39

    Tried with sudo and it worked !!

    sudo npm install --global gulp-cli
    
    0 讨论(0)
提交回复
热议问题