[英]Error starting server with nodemon
So i am running an simple express web app, i install nodemon modules so i dont have to restart the server, but apparently there is an error所以我正在运行一个简单的 express web 应用程序,我安装了 nodemon 模块,所以我不必重新启动服务器,但显然有一个错误
This is the error这是错误
events.js:141
throw er; // Unhandled 'error' event
I installed nodemon through npm and i installed it globally (into appdata/npm) My server code is quite simple, here:我通过 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 !");
);
Can anyone help me please, i really want this feature as it is very convenient for nodejs, thanks a lot !谁能帮帮我,我真的很想要这个功能,因为它对 nodejs 来说非常方便,非常感谢!
If you are using windows make sure to set如果您使用的是 Windows,请确保设置
%SystemRoot%\system32; /// this is c:\Windows\system32
in environment path.在环境路径中。
Add the following to your package.json
将以下内容添加到您的
package.json
{
"scripts": {
"start": "nodemon index.js"
}
}
Then npm start
should be enough to run your application.然后
npm start
应该足以运行您的应用程序。 You should also consider putting nodemon
as a dev dependency.您还应该考虑将
nodemon
作为开发依赖项。
Open the windows powershell and add this line.打开 windows powershell 并添加这一行。
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.