Nodemon错误events.js:182?

时间:2017-11-04 20:32:07

标签: node.js nodemon

当我尝试通过nodemon通过键入nodemon app.jsnodemon启动我的app.js时。

然后我在终端中收到以下错误: https://i.stack.imgur.com/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)

我的app.js文件是:

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! ;-)");
});

我的package.json是:

{
  "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"
  }
}

1 个答案:

答案 0 :(得分:1)

我已修复此问题..我必须将c:\ windows \ system32添加到我的环境变量(PATH)中!苦苦挣扎,但终于得到了答案。