Search code examples
npmgulpnpm-scripts

How to do npm scripts work vs direct commands?


I keep seeing this behavior, so I want to understand it. I install gulp and the gulp-cli (not globally). Typing the gulp command gives me -bash: gulp: command not found

I take the gulp command and drop it into an npm script and boom, it works. Can someone explain what's going on here?

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "gulp": "gulp", // This works!!
    "gulp-build": "gulp build" // As does this!!
  },

Solution

  • Ahh, that makes sense. I was looking for the relative path to gulp in the project couldn't find the right path. Indeed ./node_modules/.bin/gulp does work. And thank you RobC for quoting that telling line in the docs. Totally makes sense now!