$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>javascript - Running Gulp via NPM? - Stack Overflow|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Running Gulp via NPM? - Stack Overflow

matteradmin15PV0评论

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?

Share Improve this question edited Jul 18, 2024 at 4:51 midnight-coding 3,2573 gold badges18 silver badges31 bronze badges asked Feb 3, 2018 at 21:46 OleOle 47.6k70 gold badges238 silver badges447 bronze badges 2
  • The point would be, that 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
  • Consider just using npx gulp without using scripts. – zzzzBov Commented Feb 3, 2018 at 22:05
Add a ment  | 

1 Answer 1

Reset to default 7

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 scriptsentries.

See https://blog.jayway./2014/03/28/running-scripts-with-npm/ for an introduction and details.

Post a comment

comment list (0)

  1. No comments so far