使用 nodemon 启动服务器时出错

Error starting server with nodemon

所以我 运行 一个简单的 express web 应用程序,我安装了 nodemon 模块所以我不必重新启动服务器,但显然有一个错误

这是错误

events.js:141
  throw er; // Unhandled 'error' event

我通过 npm 安装了 nodemon 并且我在全局安装了它(到 appdata/npm) 我的服务器代码很简单,在这里:

const EXPR = require('express');

// set up express app
const APP = EXPR();

// Handle get request
APP.get('/', function(req, res){
   console.log('GET request');
   res.send({"name":"Yoshi"});
});
// listen for request
APP.listen(process.env.port || 2000, function(){
   console.log("Now listening for request !");
);

谁能帮帮我,我真的很想要这个功能,因为它对 nodejs 来说非常方便,非常感谢!

如果您正在使用 windows,请务必设置

%SystemRoot%\system32;  /// this is c:\Windows\system32

在环境路径中。

将以下内容添加到您的 package.json

{
  "scripts": {
    "start": "nodemon index.js"
  }
}

那么 npm start 应该足以 运行 您的申请。您还应该考虑将 nodemon 作为开发依赖项。

打开 windows powershell 并添加这一行。

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser