NODEMON - 应用程序崩溃 - 在启动之前等待文件更改 [英] NODEMON -- app crashed - waiting for file changes before starting

查看:142
本文介绍了NODEMON - 应用程序崩溃 - 在启动之前等待文件更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习本教程.

当我运行 npm run server 时,如视频中的 13:10,我收到错误:

When I run npm run server, as at 13:10 in the video, I get the error:

[nodemon] 应用程序崩溃 - 在开始之前等待文件更改...

为什么会这样?端口 5000 是否已在使用中?

Why does this happen? Is Port 5000 already in use?

这是终端:

#########:MERN_SHOPPING_LIST #######$ npm run server

mern_shopping_list@1.0.0 server /Users/MyName/Documents/Web Dev/MERN_SHOPPING_LIST
nodemon server.js
[nodemon] 1.18.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
/Users/MyName/Documents/Web Dev/MERN_SHOPPING_LIST/server.js:1
(function (exports, require, module, __filename, __dirname) { const express = required('express');
                                                                              ^
ReferenceError: required is not defined
    at Object.<anonymous> (/Users/MyName/Documents/Web Dev/MERN_SHOPPING_LIST/server.js:1:79)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
[nodemon] app crashed - waiting for file changes before starting...

推荐答案

这是一个错字.

首先,这个 (function (exports, require, module, __filename, __dirname) { ... }) 是什么?它是模块包装函数.抛出异常时,模块已经有了它的包装函数.

That's a typo.

First, what is this (function (exports, require, module, __filename, __dirname) { ... })? It's the module wrapper function. When the exception was thrown, the module already had its wrapper function.

让我们来看看错误.

1 > const express = required('express');
                           ^

这就是你的错字所在.

现在让我们进入[nodemon].

您收到来自[nodemon]"的错误消息的原因;是因为您正在为服务器使用名为 nodemon 的开发工具.

The reason why you got the error message from "[nodemon]" is because you are using a development tool called nodemon for the server.

这篇关于NODEMON - 应用程序崩溃 - 在启动之前等待文件更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆