Installations
npm install gulp-nodemon
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
10.17.0
NPM Version
6.11.3
Score
50.1
Supply Chain
83.9
Quality
66.4
Maintenance
50
Vulnerability
97.9
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
JacksonGariety
Download Statistics
Total Downloads
21,698,775
Last Day
4,043
Last Week
27,650
Last Month
137,811
Last Year
1,788,966
GitHub Statistics
526 Stars
150 Commits
76 Forks
15 Watching
10 Branches
25 Contributors
Bundle Size
487.26 kB
Minified
145.90 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.5.0
Package Id
gulp-nodemon@2.5.0
Size
4.84 kB
NPM Version
6.11.3
Node Version
10.17.0
Publised On
04 Mar 2020
Total Downloads
Cumulative downloads
Total Downloads
21,698,775
Last day
-27.7%
4,043
Compared to previous day
Last week
-8.4%
27,650
Compared to previous week
Last month
-13%
137,811
Compared to previous month
Last year
-11.4%
1,788,966
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
6
gulp-nodemon
gulp + nodemon + convenience
Install
1$ npm install --save-dev gulp-nodemon
Usage
Gulp-nodemon is almost exactly like regular nodemon, but it's made for use with gulp tasks.
nodemon([options])
Gulp-nodemon takes an options object just like the original.
Example below will start server.js
in development
mode and watch for changes, as well as watch all .html
and .js
files in the directory.
1gulp.task('start', function (done) { 2 nodemon({ 3 script: 'server.js' 4 , ext: 'js html' 5 , env: { 'NODE_ENV': 'development' } 6 , done: done 7 }) 8})
Synchronous Build Tasks
NOTE: This feature requires Node v0.12 because of child_process.spawnSync
.
Gulp-nodemon can synchronously perform build tasks on restart.
{ tasks: [Array || Function(changedFiles)] }
If you want to lint your code when you make changes that's easy to do with a simple event. But what if you need to wait while your project re-builds before you start it up again? This isn't possible with vanilla nodemon, and can be tedious to implement yourself, but it's easy with gulp-nodemon:
1nodemon({ 2 script: 'index.js' 3, tasks: ['browserify'] 4})
What if you want to decouple your build processes by language? Or even by file? Easy, just set the tasks
option to a function. Gulp-nodemon will pass you the list of changed files and it'll let you return a list of tasks you want run.
NOTE: If you manually restart the server (rs
) this function will receive a changedFiles === undefined
so check it and return the tasks
because it expects an array to be returned.
1nodemon({ 2 script: './index.js' 3, ext: 'js css' 4, tasks: function (changedFiles) { 5 var tasks = [] 6 if (!changedFiles) return tasks; 7 changedFiles.forEach(function (file) { 8 if (path.extname(file) === '.js' && !~tasks.indexOf('lint')) tasks.push('lint') 9 if (path.extname(file) === '.css' && !~tasks.indexOf('cssmin')) tasks.push('cssmin') 10 }) 11 return tasks 12 } 13})
Events
gulp-nodemon returns a stream just like any other NodeJS stream, except for the on
method, which conveniently accepts gulp task names in addition to the typical function.
.on([event], [Array || Function])
[event]
is an event name as a string. See nodemon events.[tasks]
An array of gulp task names or a function to execute.
.emit([event])
event
is an event name as a string. See nodemon events.
Examples
Basic Usage
The following example will run your code with nodemon, lint it when you make changes, and log a message when nodemon runs it again.
1// Gulpfile.js 2var gulp = require('gulp') 3 , nodemon = require('gulp-nodemon') 4 , jshint = require('gulp-jshint') 5 6gulp.task('lint', function () { 7 gulp.src('./**/*.js') 8 .pipe(jshint()) 9}) 10 11gulp.task('develop', function (done) { 12 var stream = nodemon({ script: 'server.js' 13 , ext: 'html js' 14 , ignore: ['ignored.js'] 15 , tasks: ['lint'] }) 16 , done: done 17 18 stream 19 .on('restart', function () { 20 console.log('restarted!') 21 }) 22 .on('crash', function() { 23 console.error('Application has crashed!\n') 24 stream.emit('restart', 10) // restart the server in 10 seconds 25 }) 26})
You can also plug an external version or fork of nodemon
1gulp.task('pluggable', function() { 2 nodemon({ nodemon: require('nodemon'), 3 script: 'server.js'}) 4})
Bunyan Logger integration
The bunyan logger includes a bunyan
script that beautifies JSON logging when piped to it. Here's how you can you can pipe your output to bunyan
when using gulp-nodemon
:
1gulp.task('run', ['default', 'watch'], function(done) { 2 var nodemon = require('gulp-nodemon'), 3 spawn = require('child_process').spawn, 4 bunyan 5 6 nodemon({ 7 script: paths.server, 8 ext: 'js json', 9 ignore: [ 10 'var/', 11 'node_modules/' 12 ], 13 watch: [paths.etc, paths.src], 14 stdout: false, 15 readable: false, 16 done: done 17 }) 18 .on('readable', function() { 19 20 // free memory 21 bunyan && bunyan.kill() 22 23 bunyan = spawn('./node_modules/bunyan/bin/bunyan', [ 24 '--output', 'short', 25 '--color' 26 ]) 27 28 bunyan.stdout.pipe(process.stdout) 29 bunyan.stderr.pipe(process.stderr) 30 31 this.stdout.pipe(bunyan.stdin) 32 this.stderr.pipe(bunyan.stdin) 33 }); 34})
Using gulp-nodemon
with React, Browserify, Babel, ES2015, etc.
Gulp-nodemon is made to work with the "groovy" new tools like Babel, JSX, and other JavaScript compilers/bundlers/transpilers.
In gulp-nodemon land, you'll want one task for compilation that uses an on-disk cache (e.g. gulp-file-cache
, gulp-cache-money
) along with your bundler (e.g. gulp-babel
, gulp-react
, etc.). Then you'll put nodemon({})
in another task and pass the entire compile task in your config:
1var gulp = require('gulp') 2 , nodemon = require('gulp-nodemon') 3 , babel = require('gulp-babel') 4 , Cache = require('gulp-file-cache') 5 6var cache = new Cache(); 7 8gulp.task('compile', function () { 9 var stream = gulp.src('./src/**/*.js') // your ES2015 code 10 .pipe(cache.filter()) // remember files 11 .pipe(babel({ ... })) // compile new ones 12 .pipe(cache.cache()) // cache them 13 .pipe(gulp.dest('./dist')) // write them 14 return stream // important for gulp-nodemon to wait for completion 15}) 16 17gulp.task('watch', ['compile'], function (done) { 18 var stream = nodemon({ 19 script: 'dist/' // run ES5 code 20 , watch: 'src' // watch ES2015 code 21 , tasks: ['compile'] // compile synchronously onChange 22 , done: done 23 }) 24 25 return stream 26})
The cache keeps your development flow moving quickly and the return stream
line ensure that your tasks get run in order. If you want them to run async, just remove that line.
Using gulp-nodemon
with browser-sync
Some people want to use browser-sync
. That's totally fine, just start browser sync in the same task as nodemon({})
and use gulp-nodemon's .on('start', function () {})
to trigger browser-sync. Don't use the .on('restart')
event because it will fire before your app is up and running.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 5/12 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 23 are checked with a SAST tool
Reason
31 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-897m-rjf5-jp39
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
1.8
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More