Nodemon运行表达错误

时间:2015-11-21 11:41:11

标签: node.js express nodemon

我正在学习快递,我正在运行此代码:

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);

当我尝试像这样执行它时,它可以工作:

node app.js

但是当我尝试以这种方式运行时:

nodemon app.js

发生这种情况:

[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)

似乎有什么问题?

1 个答案:

答案 0 :(得分:0)

请重新启动计算机并再次尝试。 就我而言,它有所帮助。