2

I'm learning express, and I'm running this code:

var express = require('express');
var app = express();

var port = process.env.PORT || 3000;

app.get('/', function(req, res) {
    res.send('<html><head></head><body><h1>Hello World!</h1></body></html>');
});

app.get('/api', function(req,res) {
    res.json({ firstname: 'John', lastname: 'Doe'})
});

app.listen(port);

When I try to execute it like this, it works:

node app.js

But when I try to run it this way:

nodemon app.js

This happens:

[nodemon] 1.8.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node app.js`
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: spawn cmd ENOENT
    at exports._errnoException (util.js:874:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at doNTCallback2 (node.js:441:9)
    at process._tickCallback (node.js:355:17)

What seems to be the problem?

Louie Cubero
  • 329
  • 1
  • 3
  • 11
  • check this out https://github.com/remy/nodemon/issues/504 and http://stackoverflow.com/questions/30974833/what-is-the-issue-node-is-working-but-nodemon-is-not-woking-on-windows-7-64 most of people had C:\Windows\System32\ missing in the PATH and ya plz check if all packages are installed – Aishwat Singh Nov 21 '15 at 11:58
  • What do you mean "missing in the PATH?", all the packages are installed. I can run the application with node command. – Louie Cubero Nov 21 '15 at 12:07
  • Have you checked the system environment variables path. This may help you.You can find it here: http://stackoverflow.com/questions/28624686/get-spawn-cmd-enoent-when-try-to-build-cordova-application-event-js85 – Ketha Kavya Nov 21 '15 at 12:34
  • Thanks Ketha! It's working now! :D – Louie Cubero Nov 21 '15 at 13:19

1 Answers1

0

Please restart your computer and try it again. In my case it helped.