This tutorial runs Gulp via NPM like this:
// package.json
"scripts": {
"gulp": "./node_modules/gulp/bin/gulp.js"
},
// in your terminal, instead of using gulp, use npm run gulp
npm run gulp
Would this work equally well:
// package.json
"scripts": {
"gulp": "npm run gulp"
}
IIUC npm will look in the node_modules/gulp/bin
directory for the gulp binary?
This tutorial runs Gulp via NPM like this:
// package.json
"scripts": {
"gulp": "./node_modules/gulp/bin/gulp.js"
},
// in your terminal, instead of using gulp, use npm run gulp
npm run gulp
Would this work equally well:
// package.json
"scripts": {
"gulp": "npm run gulp"
}
IIUC npm will look in the node_modules/gulp/bin
directory for the gulp binary?
gulp
(from nodes_modules/.bin
) may not be on the user's PATH, if it is not installed globally. So npm run gulp
would be a clean and portable way to run it. The scripts
entry is not needed, though.
– pixelistik
Commented
Feb 3, 2018 at 21:59
npx gulp
without using scripts.
– zzzzBov
Commented
Feb 3, 2018 at 22:05
Yes, you can simply use
// package.json
"scripts": {
"gulp": "gulp"
}
npm will look in the node_modules/.bin
directory, where each installed module creates symlinks to the relevant bin entry points.
But: In this case, you don't even need the entry for gulp
. You can run all existing mands in .bin
with npm run
, without making explicit scripts
entries.
See https://blog.jayway./2014/03/28/running-scripts-with-npm/ for an introduction and details.