search

Home  >  Q&A  >  body text

node.js - I only want to install gulp locally on mac, how to run the gulp command?

I only want to install gulp locally on mac, how to run the gulp command

PHPzPHPz2729 days ago1505

reply all(7)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-06-07 09:26:20

    npm script

    Add

    gulpscript to `scripts` of package.json

      "scripts": {
        "gulp": "gulp"
      }
    npm run gulp -- --version

    The disadvantage of this method is that it can only be run under the current project

    Environment variables

    Find the gulp installation directory <gulp-install-dir>, and then add the directory <gulp-install-dir>/node_modules/.bin to the environment variable

    reply
    0
  • 三叔

    三叔2017-06-07 09:26:20

    I don’t quite understand your question. I only want to install it locally. Does it mean that gulp is not included when deployed to the server?

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-06-07 09:26:20

    Using npm run can solve this problem.
    Or when executing gulp in the current directory, writing ./gulp can also solve the problem.

    I don’t understand the reason for not installing gulp globally.

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-06-07 09:26:20

    Run it directly under your project

    ./node_modules/.bin/gulp

    It is recommended to install it globally or use npm script as other answerers said

    // package.json
    
    {
      "devDependencies": {
        "gulp": "^3.9.1"
      },
      "scripts": {
        "start": "gulp"
      }
    }

    Run

    npm start

    reply
    0
  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-06-07 09:26:20

    You cannot use the gulp command directly in the terminal without sudo to install gulp globally.

    Alternatively, you can write "gulp": "gulp xxx" in the npm script of package.json to use npm run gulp to run the gulp installed in the project

    reply
    0
  • 为情所困

    为情所困2017-06-07 09:26:20

    npm run ‘xx’ way. Don't run gulp directly.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-06-07 09:26:20

    Don’t want to install it globally, but want to use gulp in the command line?

    Try npm link ?

    https://docs.npmjs.com/cli/link
    http://javascript.ruanyifeng....
    https://github.com/atian25/bl...

    reply
    0
  • Cancelreply