admin管理员组文章数量:1435859
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?
-
The point would be, that
gulp
(fromnodes_modules/.bin
) may not be on the user's PATH, if it is not installed globally. Sonpm run gulp
would be a clean and portable way to run it. Thescripts
entry is not needed, though. – pixelistik Commented Feb 3, 2018 at 21:59 -
Consider just using
npx gulp
without using scripts. – zzzzBov Commented Feb 3, 2018 at 22:05
1 Answer
Reset to default 7Yes, 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.
本文标签: javascriptRunning Gulp via NPMStack Overflow
版权声明:本文标题:javascript - Running Gulp via NPM? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745673662a2669720.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论