javascript - Running Gulp via NPM? - Stack Overflow
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.
- 互联网“一哥”百度不行了?
- 下个月Win7正式“退休”,数据显示国内近60%电脑用户仍在使用
- 死忠安卓粉看iPhone 6S:根本没创新!
- 软件定义网络:正在进行的网络变革
- Mac电脑与PC九大区别
- 研究机构:平板四年内将成主流计算设备
- Can I Trigger Console Application From Window Service in Visual Studio c#? - Stack Overflow
- filename has 'netboxlabs-diode-netbox-plugin', but metadata has 'unknown' - Stack Overflow
- linux - Zowe Config Error popping up on VSCODE? How may I fix this error? - Stack Overflow
- c++ - std::rethrow_exception with std::current_exception - Stack Overflow
- reactjs - Flatlist scrolling freeze - Stack Overflow
- Trouble installing homebrew with ansible playbook, linux client and host nodes - Stack Overflow
- Assigning Latitude and Longitude to Turtles in NetLogo from a GIS Map - Stack Overflow
- Why is my bot not able to detect when a user leaves in Telegram? - Stack Overflow
- Rust error: lifetime may not live long enough, how to express lifetimes? - Stack Overflow
- reactjs - Google Books API setOnLoadCallback works only after page reload - Stack Overflow
- Spring Boot Application in Docker Container Shuts Down Immediately After Startup - Stack Overflow