gimm / gulp-express

gulp plugin for express
56 stars 26 forks source link

Spawn Errors #27

Closed johngeorgewright closed 9 years ago

johngeorgewright commented 9 years ago

Hey there,

Just to warn you, you made a non backwards compatible API change in your last patch release... so beware of some issues opening up your way :wink: Certainly took me awhile to figure out what was going wrong.

Since the update I'm also getting spawn errors and I have no idea why.

server.run(['app/index.js'], {
  cwd: ROOT_DIR,
  env: process.NODE_ENV,
  port: 8080
});
Error: spawn ENOENT
    at errnoException (child_process.js:1011:11)
    at Process.ChildProcess._handle.onexit (child_process.js:802:34)
Service process exited with [code => 1 | sig => undefined]

Anything look incorrect?

gimm commented 9 years ago

As far as I can tell, the env should be an object, not string. You can check the readme. I know the last update was not compatible, but I don't know how to warn or make it clear for you guys. Any ideas?

johngeorgewright commented 9 years ago

Just do a major release. Then we won't get the update unless we do it manually.

johngeorgewright commented 9 years ago

Just tried changing it to an object and also tried removing the argument all together. Just can't get it to work :(

I'll keep trying.

gimm commented 9 years ago

If you like, you can post your gulpfile.js here, and I'll try to be of any help.

azhawkes commented 9 years ago

I'm getting the same ENOENT error as @johngeorgewright, and unable to get it to run the server at all.

Here is my gulpfile.js:

var gulp = require('gulp');
var server = require('gulp-express');

gulp.task('serve', function() {
    server.run(['test/harness.js']);
});

And here are my versions:

  "devDependencies": {
    "connect-livereload": "^0.5.3",
    "gulp": "^3.8.10",
    "gulp-express": "^0.1.8",
    "gulp-mocha": "^2.0.0",
    "mocha": "~1.13.0",
    "should": "~4.3.1"
  },

I'm using Node 10.33.

dflynn15 commented 9 years ago

This also occurred on my machine. I downgraded to 0.1.7 in order to get it running again.

gimm commented 9 years ago

@azhawkes could you please help to check if you can run node in your terminal?

gimm commented 9 years ago

Gyus, sorry for the inconvenience, but I couldn't reproduce the problem yet. I've google "spawn ENOEOT" around, it might be that node is somehow not available, could you please try to verify this, or do a sudo execution of the gulp serve. Thanks for your feedback, and I'll keep an close eye on this, and continue searching.

pablolmiranda commented 9 years ago

There is a error only with the version 0.1.8. When I rolled back to 0.1.7 it works fine.

azhawkes commented 9 years ago

@gimm Yeah, I can run node normally in my terminal and all that. It's at /usr/local/bin/node and is version 10.33. Are you running Node 12.x by chance?

gimm commented 9 years ago

Could anyone give me the gulpfile.js and the app.js? so I can try to reproduce the problem here. I couldn't get this issue locally, I'm running node 10.36 on win7.

Now I removed this SIGINT listener in v0.1.9:

//process.on('SIGINT', mainDownListener);

please update to 0.1.9 to see if this was fixed. Thanks a lot!

pablolmiranda commented 9 years ago

The same still happening for me on 0.1.9. Even using the examples you have on the README.md.

Service process exited with [code => 1 | sig => undefined]

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:1000:11)
    at Process.ChildProcess._handle.onexit (child_process.js:791:34)
gimm commented 9 years ago

Could anyone send me the copy of your project so that I can check and find the reason? appreciate that.

And if there's not too much trouble, I'd like to ask you to help verify this spawn ENOENT error is introuduce by gulp-express, by runing node app.js and refresh your browser.

As I just reviewed one project, turns out the spawn error is caused by node-compass.

varya commented 9 years ago

I have the same Service process exited with [code => 1 | sig => undefined] error after moving from 0.1.7 to 0.1.9. Cannot give you link to the repo (it's private) but here is the code https://gist.github.com/varya/90d8ce39f6f402e941ce

gimm commented 9 years ago

@varya Thanks for your feedback. I've tried your code locally, works fine for me, with livereload. Could you please try to check if the spawn error was introduced by gulp-express?

whisher commented 9 years ago

mmm just a lot of folks :) same issue with the last version :( if you want to try https://github.com/whisher/rock-paper-scissors-multiplayer

willywongi commented 9 years ago

Hey there. I looked at the latest commits and I found that having moved the env options from process to child_process.spawn broke the thing. I'm no expert so I'm not sure about what those changes were for. @gimm, would you please check your changes in commit#5834d4b?

gimm commented 9 years ago

@whisher your project is not so simple, I didn't go through it yet. @willywongi commit#5834d4b was aimed to open up the flexibility of the arguments for child_process.spawn, I won't believe this change broke the thing.

gimm commented 9 years ago

@whisher you app works for me, with livereload, no errors.

whisher commented 9 years ago

@gimm Sorry to bother you but in my localhost doesn't work yet.What's your node version ?

varya commented 9 years ago

@gimm,

I created a stub project to demonstrate the problem https://github.com/varya/gulp-express-stub

In the master branch the is a working example based on 0.1.7. Type gulp to run it. Another branch based on 0.1.9 does not work https://github.com/varya/gulp-express-stub/tree/update-gulp-express

This is the output when running the broken version

Service process exited with [code => 1 | sig => undefined]

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:1011:11)
    at Process.ChildProcess._handle.onexit (child_process.js:802:34)

Others, if you can confirm that 0.1.9 does not work in this simple project for you, please do.

In here you can see that the only difference between branches is switching to a new version and API change of server.run method. https://github.com/varya/gulp-express-stub/pull/1/files

My node version is 0.10.36.

whisher commented 9 years ago

The problem is with options parameter
like this

service = child_process.spawn('node', args);

works fine

whisher commented 9 years ago

http://stackoverflow.com/a/27716861/356380

this works for me

var env = Object.create( process.env );
env.NODE_ENV = 'development';
service = child_process.spawn('node', args, { env : env, port : 35729});
gimm commented 9 years ago

@whisher thanks, I have made changes to set a new default options like this:

defaults = {
            args: ['app.js'],
            options: {
                cwd: undefined,
                port: 35729
            }
        };
    defaults.options.env = process.env;
    defaults.options.env.NODE_ENV = 'development';

this should solve spawn ENOENT error here.

@varya I still can fire up your app without error, but I had updated the plugin, please give it a try, sorry for the trouble here.

whisher commented 9 years ago

@gimm yaw, thanks to you to share :)

varya commented 9 years ago

Could you release 0.1.10 with this change? This should fix my case too.

gimm commented 9 years ago

new release is there already https://www.npmjs.com/package/gulp-express please let me know if this works for you thanks

varya commented 9 years ago

Yes, this works, thank you!

gimm commented 9 years ago

I should go to bed now :smile: have a nice day