gulp-nodemon icon indicating copy to clipboard operation
gulp-nodemon copied to clipboard

nodemon.tasks does not work on Windows

Open m-ghaoui opened this issue 9 years ago • 10 comments

var Path = require('path');

var gulp = require('gulp'),
    jshint = require('gulp-jshint'),
    nodemon = require('gulp-nodemon');

gulp.task('jshint', function() {
    return gulp.src('*.js')
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

gulp.task('watch', function() {
    nodemon({
        script: Path.resolve('index.js'),
        ext: 'js html',
        tasks: ['jshint'] // doesn't work on Windows
    });
});

The above code is a simple task for monitoring a hapijs server. The nodemon reloads the server but the tasks: ['jshint'] does not execute.

I did a small bit of debugging and it looks like this line in the code does not seem to do anything:

cp.spawnSync('gulp', tasks, { stdio: [0, 1, 2] })

Link to source: https://github.com/JacksonGariety/gulp-nodemon/blob/master/index.js#L74

I get no error or feedback.

I changed this line to gulp.run(tasks) (just to test it) and that worked, but you get a warning that gulp.run() is obsolete and should not be used.

m-ghaoui avatar Jul 21 '15 17:07 m-ghaoui

Running on nodejs 0.12.7

If you're curious about the code, it's here:

https://github.com/Yuioup/hapi-test

It's not very exciting.

m-ghaoui avatar Jul 21 '15 18:07 m-ghaoui

It works on Linux BTW

m-ghaoui avatar Jul 21 '15 18:07 m-ghaoui

Confirmed: I'm having the same issue on Windows 7, with Node.js v0.12.7.

Thanks for the temporary workaround, @Yuioup.

gaborluk avatar Jul 27 '15 09:07 gaborluk

I'm getting this problem too. Cheers for the work-around!

egbulmer avatar Jul 30 '15 03:07 egbulmer

@Yuioup I don't have a windows system. Would you try removing the stdio: [] part and see if you get some feedback on the console when that line is reached?

ColemanGariety avatar Aug 21 '15 16:08 ColemanGariety

I had this problem on Ubuntu 15.10. I had the same problem where

cp.spawnSync(process.platform === 'win32' ? 'gulp.cmd' : 'gulp', tasks, { stdio: [0, 1, 2] })

had no effect. This is because it assumes that gulp is installed globally.

Installing gulp globally seemed to do the trick. I guess the correct behaviour here would be to check for a local one, then fallback to global if local doesn't exist.

robbie-c avatar Nov 18 '15 14:11 robbie-c

Also problem on Xubuntu 14.04 LTS, [email protected] installed globally with gulp aswell and Node v4.3.1. tasks option is "ignored".

It worked on latest OS X [email protected] and Node v4.1.2

snovak7 avatar Mar 03 '16 21:03 snovak7

As robbie-c wrote three months ago, still doesn't work on Ubuntu when gulp not installed globally.

marzelin avatar Mar 07 '16 12:03 marzelin

I'm having this problem on a MAC in both installed cases, locally or globally.

firebait avatar May 05 '16 06:05 firebait

Same problem inside a Docker container (node:4 and node:6) on Ubuntu 14.04 LTS. Installing gulp globally in the container solved it

MatthewPolak avatar May 06 '16 15:05 MatthewPolak