Search code examples
node.jsnodemon

Nodemon error events.js:182?


when I try to start my app.js via nodemon by typing nodemon app.js or just nodemon.

I then get the following error in my terminal: https://i.sstatic.net/1UYK4.png

PS C:\Users\ered0c\Coding\NodeJs\ESJDemo> nodemon app.js

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

Error: spawn cmd ENOENT
    at _errnoException (util.js:1024:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:192:19)
    at onErrorNT (internal/child_process.js:374:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

my app.js file is:

var express = require("express")();

express.get("/", function(req, res) {
  res.render("home.ejs");
});

express.get("/fallinlovewith/:thing", function(req, res) {
  var thing = req.params.thing;
  res.render("love.ejs", {thingVar: thing});
});

express.get("/posts", function(req, res) {
  var posts = [
    {title: "Post is cool", author: "Susy"},
    {title: "My adorable pet Poem", author: "Akash"},
    {title: "I have a cat", author: "Colt"}
  ];

  res.render("posts.ejs", {posts: posts});
});
express.listen(process.env.PORT || 3000, function() {
  console.log("Server is listening at port 3000! ;-)");
});

my package.json is:

{
  "name": "esjdemo",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Akash Soedamah",
  "license": "ISC",
  "dependencies": {
    "ejs": "^2.5.7",
    "express": "^4.16.2",
    "nodemon": "^1.12.1"
  }
}

Solution

  • I have fixed the issue.. I had to add c:\windows\system32 to my Environment Variables (PATH)! Struggled with it but finally got the answer.