DEV Community

Cover image for Farewell, Nodemon! ๐Ÿ’”

Farewell, Nodemon! ๐Ÿ’”

Bilal Asghar on August 04, 2023

Nodemon has been our trusty friend, helping Node.js developers by automatically restarting our servers whenever we made changes to our code. So if...
Collapse
 
alice58 profile image
Alice ๐ŸŒˆ • Edited

To be honestly, gulp's file watch thingy works much better than nodemon.

I used that code snipper through my career to quickly set it up

// gulpfile.js
const gulp = require('gulp');
const spawn = require('child_process').spawn;

gulp.task('start_dev', (cb) => {
    console.log('Running in dev mode');

    const spawn_node = () => {
        return spawn('node', [ '--inspect=0.0.0.0:9229', 'src/index.js' ], { stdio: 'inherit' });
    }

    let node = spawn_node();

    function files(cb) {
        console.log('Restarting node');
        node.kill('SIGTERM');
        node = spawn_node();
        cb();
    }

    gulp.watch('**', { events: 'all' }, files);

    cb();
})
Enter fullscreen mode Exit fullscreen mode

Then just run npx gulp start_dev to start it up

Collapse
 
malikbilal111 profile image
Bilal Asghar

Absolutely, I appreciate your input! ๐Ÿงก