简体   繁体   English

使用 nodemon 启动服务器时出错

[英]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.

相关问题 在我的server.js文件(Nodejs)上启动Nodemon时出错 - Error when starting Nodemon on my server.js file (Nodejs) 使用 Nodemon 时服务器未启动或连接 - Server is not starting or connecting when using Nodemon nodemon 应用程序崩溃 - 在从服务器获得响应后开始错误之前等待文件更改 - nodemon app crashed - waiting for file changes before starting error after geting response from server 然后将 nodemon 服务器与 MongoDB 连接时出错 - Error then connecting nodemon server with MongoDB 当我运行 nodemon 服务器时,我收到错误消息“错误的身份验证失败。[nodemon] 应用程序崩溃 - 在开始之前等待文件更改......” - When I run nodemon server I get the error "bad auth Authentication failed. [nodemon] app crashed - waiting for file changes before starting..." nodemon 启动 `node server.js` TypeError: marked is not a function - nodemon starting `node server.js` TypeError: marked is not a function Express.js 服务器未启动 post-nodemon 安装 - Express.js server not starting post-nodemon install 错误 [nodemon] 应用程序崩溃 - 在启动前等待文件更改 - an Error [nodemon] app crashed - waiting for file changes before starting mondoDB 的 Nodemon 错误:“应用程序崩溃 - 启动前等待文件更改” - Nodemon error with mondoDB: “ app crashed - waiting for file changes before starting” nodemon 应用程序崩溃 - 在开始之前等待文件更改...错误 - nodemon app crashed - waiting for file changes before starting ... Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM