admin管理员组

文章数量:1415111

From time to time it does happen, but restarting the node bypass this. I really don't have how to debug and see the actual error and the site needs to be online anyway.

I wish to know a way to restart the server whet this error happens, without having to change a file or anything like that.

I know this is a way around, etc etc... but that's what I need to do now...

ERROR:

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

PACKAGE.json

 "scripts": {
            "test": "echo \"Error: no test specified\" && exit 1",
            "start": "node app.js",
            "server": "nodemon app --ignore './client/'",
            "client": "npm start --prefix client",
            "dev": "concurrently \"npm run server\" \"npm run client\"",
            "build": "concurrently \"npm run server\" \"npm run client\""
        },

starting using node server.

From time to time it does happen, but restarting the node bypass this. I really don't have how to debug and see the actual error and the site needs to be online anyway.

I wish to know a way to restart the server whet this error happens, without having to change a file or anything like that.

I know this is a way around, etc etc... but that's what I need to do now...

ERROR:

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

PACKAGE.json

 "scripts": {
            "test": "echo \"Error: no test specified\" && exit 1",
            "start": "node app.js",
            "server": "nodemon app --ignore './client/'",
            "client": "npm start --prefix client",
            "dev": "concurrently \"npm run server\" \"npm run client\"",
            "build": "concurrently \"npm run server\" \"npm run client\""
        },

starting using node server.

Share Improve this question edited Jan 30 at 7:22 DarkBee 15.5k8 gold badges72 silver badges118 bronze badges asked Mar 22, 2022 at 16:34 DatafinderDatafinder 571 gold badge1 silver badge5 bronze badges 4
  • If you have not done it already, review answers for stackoverflow./questions/37486631/… – PM 77-1 Commented Mar 22, 2022 at 16:38
  • I know this is a way around, etc etc... but that's what I need to do now...” Can you elaborate as to why this is the imperative, as opposed to investing the same time into actually fixing the cause of the crash itself? What you’re asking for is bound to lead to data integrity issues, horrendous UXs, oversized/polluted log files… etc. depending on your program’s use case. – esqew Commented Mar 22, 2022 at 16:49
  • @PM77-1 Thanks. I checked it! – Datafinder Commented Mar 24, 2022 at 14:10
  • @esqew Im not a react developer, but I have a good experience in developing other languages and infrastructure. My actual developer is not avaiable anymore and I'm trying to do my best to keep the app up and running. I already spent lots of time trying to solve this but I couldn't. – Datafinder Commented Mar 24, 2022 at 14:13
Add a ment  | 

3 Answers 3

Reset to default 1

This occurred because the process was exited in a non-graceful way. If you want auto-restart after crashing, that's not the purpose of nodemon.

I would remend pm2

You could try using forever as advised in the nodemon FAQ.

forever -c "nodemon --exitcrash" app.js

This way if the script crashes, forever restarts the script, and if there are file changes, nodemon restarts your script.

If you are getting error in src/app.ts or you are using TypeScript then run following mand

npm i --save-dev ts-node

this is working for me.

本文标签: