Gulp command not found after install

前端 未结 11 1413
抹茶落季
抹茶落季 2021-01-30 01:54

I installed gulp(globally) and it looks like it worked because it ran this code:

├── tildify@0.2.0
├── interpret@0.3.5
├── pretty-hrtime@0.2.1
├── deprecated@0.0         


        
相关标签:
11条回答
  • 2021-01-30 02:27

    I had this problem with getting "command not found" after install but I was installed into /usr/local as described in the solution above.

    My problem seemed to be caused by me running the install with sudo. I did the following.

    1. Removing gulp again with sudo
    2. Changing the owner of /usr/local/lib/node_modules to my user
    3. Installing gulp again without sudo. "npm install gulp -g"
    0 讨论(0)
  • 2021-01-30 02:28

    If you want to leave your prefix intact, just export it's bin dir to your PATH variable:
    export PATH=$HOME/your-path/bin:$PATH
    I added this line to my $HOME/.profile and sourced it.

    Setting prefix to /usr/local makes you use sudo, so I like to have it in my user dir. You can check your prefix with npm prefix -g.

    0 讨论(0)
  • 2021-01-30 02:31

    Turns out that npm was installed in the wrong directory so I had to change the “npm config prefix” by running this code:

    npm config set prefix /usr/local
    

    Then I reinstalled gulp globally (with the -g param) and it worked properly.

    This article is where I found the solution: http://webbb.be/blog/command-not-found-node-npm

    0 讨论(0)
  • 2021-01-30 02:32

    If you're using tcsh (which is my default shell on Mac OS X), you probably just need to type rehash into the shell just after the install completes:

    npm install -g gulp
    

    followed immediately by:

    rehash
    

    Otherwise, if this is your very first time installing gulp, your shell may not recognize that there's a new executable installed -- so you either need to start a new shell, or type rehash in the current shell.

    (This is basically a one-time thing for each command you install globally.)

    0 讨论(0)
  • 2021-01-30 02:33

    I had similar problem I did the following steps and it worked.Go to mac terminal and execute the commands,

    1.npm config set prefix /usr/local

    2.sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

    This two commands will set the npm path right and you no longer have to use sudo in npm. Next uninstall the gulp

    1. npm uninstall gulp

    2. Installl gulp again without sudo, npm install gulp -g

    This should work!!

    0 讨论(0)
  • 2021-01-30 02:36

    I got this working on Win10 using a combination of the answers from above and elsewhere. Posting here for others and future me.

    I followed the instructions from here: https://gulpjs.com/docs/en/getting-started/quick-start but on the last step after typing gulp --version I got the message -bash: gulp: command not found

    To fix this:

    1. I added %AppData%\npm to my Path environment variable
    2. Closed all gitbash (cmd, powershell, etc...) and restarted gitbash.
    3. Then gulp --version worked

    Also, found the below for reasons why not to install gulp globally and how to remove it (not sure if this is advisable though):

    what does gulp-"cli" stands for?

    How to uninstall Gulp CLI from NPM globally?

    0 讨论(0)
提交回复
热议问题