NODEMON — app crashed - waiting for file changes before starting

ぃ、小莉子 提交于 2020-05-28 04:35:06

问题


I'm following this tutorial.

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

[nodemon] app crashed - waiting for file changes before starting...

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


Here's the terminal:

MyComputer:MERN_SHOPPING_LIST MyName$ 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...


回答1:


You used a word required it is rather require.

The code should be require('express'); on line 1 of the server.js file.

nodemon tries to restart the program for you anytime you encounter an error. Should you effect changes or make the necessary corrections you wouldn't need to run the command node server.js again.




回答2:


Simple Answer is:

Go to Mongodb cluster and edit the IPwhitelist and refresh it

then connect it again problem solve.

Happy Coding



来源:https://stackoverflow.com/questions/51868233/nodemon-app-crashed-waiting-for-file-changes-before-starting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!