Nodemon app crashed waiting for file changes before starting как исправить

EDIT
After further testing, I have found that this is happening with both gulp and grunt on this app and on the default install of mean.js. I’m running this locally on a Mac. When I running either app using «node server.js» they don’t crash.

I’m using a MEAN stack with grunt-nodemon and node is crashing when an express URL is accessed. It isn’t always consistent though. Sometimes it works, sometimes node crashes right when the URL is hit retiring no data, and other times I get a response and node crashed immediately after.

Browser console response:

http://localhost:8000/api/users net::ERR_CONNECTION_REFUSED

Terminal output:

Mongoose: users.insert({ firstname: 'mike', lastname: 'jones', email:'mike@gmail.com', role: 'admin', password: 'mike', _id: ObjectId("57485c16fc11894b96c28057"), created: new Date("Fri, 27 May 2016 14:39:18 GMT"), __v: 0 })   
user.save success
node crash
[nodemon] app crashed - waiting for file changes before starting...

In this case, the POST request went through, the user was added, then node crashed, but sometimes it crashes before a successful POST. Node also occasionally crashes on the GET request.

gruntfile.js:

module.exports = function(grunt) {
    // Load grunt tasks automatically
    require('load-grunt-tasks')(grunt);

    var pkg = grunt.file.readJSON('package.json');

    var options = {
        paths: {
            app: 'app',
            assets: 'app/assets',
            dist: 'app/dist',
            distAssets: 'app/dist/assets',
            html: 'app/html',
            htmlTmp: '.tmp/htmlsnapshot',
            htmlAssets: 'app/html/assets',
            index: 'app/dist/index.html',
            indexDev: 'app/index.html',
            indexTmp: '.tmp/html/index.html'
        },
        pkg: pkg,
        env: {
            test: {
                NODE_ENV: 'test'
            },
            dev: {
                NODE_ENV: 'development'
            },
            prod: {
                NODE_ENV: 'production'
            }
        }
    };

    // Load grunt configurations automatically
    var configs = require('load-grunt-configs')(grunt, options);

    // Define the configuration for all the tasks
    grunt.initConfig(configs);

    // Connect to the MongoDB instance and load the models
    grunt.task.registerTask('mongoose', 'Task that connects to the MongoDB instance and loads the application models.', function () {
        // Get the callback
        var done = this.async();

        // Use mongoose configuration
        var mongoose = require('./config/lib/mongoose.js');

        // Connect to database
        mongoose.connect(function (db) {
            done();
        });
    });

    grunt.registerTask('bumper', ['bump-only']);
    grunt.registerTask('css', ['sass']);
    grunt.registerTask('default', [
        'sass',
        'copy:dev',
        'nodemon',
        'concurrent:dev',
        'watch',
        'mongoose'
    ]);

    grunt.registerTask('shared', [
        'clean:demo',
        'copy:demo',
        'sass',
        'ngconstant',
        'useminPrepare',
        'concat:generated',
        'cssmin:generated',
        'uglify:generated',
        'filerev',
        'usemin',
        'imagemin',
        'usebanner'
    ]);

    grunt.registerTask('demo', [
        'shared',
        'copy:postusemin',
        'grep:demo'
    ]);

    grunt.registerTask('dist', [
        'shared',
        'copy:postusemin',
        'copy:dist',
        'grep:dist',
        'compress',
        'copy:postusemin',
        'grep:demo',
    ]);

    grunt.loadNpmTasks('grunt-forever');

};

default.js

module.exports.tasks = {
    // version update
    bump: {
        options: {
            files: ['package.json', 'bower.json'],
            pushTo: 'origin'
        }
    },

    // application constants
    ngconstant: {
        options: {
            dest: '<%= paths.assets %>/js/app.constants.js',
            name: 'app.constants',
        }
    },

    // remove all bs from css
    cssmin: {
        options: {
            keepSpecialComments: 0
        }
    },
    markdown: {
        all: {
            files: [
                {
                    src: 'README.md',
                    dest: '<%= paths.assets %>/tpl/documentation.html'
                }
            ],
            options: {
                template: '<%= paths.assets %>/tpl/_documentation_template.html',
            }
        }
    }
};

dev.js:

var _ = require('lodash'),
defaultAssets = require('./assets/default'),
testAssets = require('./assets/test'),
testConfig = require('./env/test'),
fs = require('fs'),
path = require('path');

module.exports.tasks = {
    // copy files to correct folders
    copy: {
        dev: {
            files: [
                { expand: true, src: '**', cwd: '<%= paths.app %>/bower_components/font-awesome/fonts',                    dest: '<%= paths.assets %>/fonts' },
                { expand: true, src: '**', cwd: '<%= paths.app %>/bower_components/material-design-iconic-font/fonts',     dest: '<%= paths.assets %>/fonts' },
                { expand: true, src: '**', cwd: '<%= paths.app %>/bower_components/roboto-fontface/fonts',                 dest: '<%= paths.assets %>/fonts' },
                { expand: true, src: '**', cwd: '<%= paths.app %>/bower_components/weather-icons/font',                    dest: '<%= paths.assets %>/fonts' },
                { expand: true, src: '**', cwd: '<%= paths.app %>/bower_components/bootstrap-sass/assets/fonts/bootstrap', dest: '<%= paths.assets %>/fonts' }
            ]
        }
    },

    // watch for changes during development
    watch: {
        js: {
            files: ['Gruntfile.js', '<%= paths.assets %>/js/**/*.js'],
            tasks: ['jshint'],
            options: {
                livereload: true
            }
        },
        css: {
            files: [
                '<%= paths.assets %>/css/**/*.scss'
            ],
            tasks: ['sass'],
            options: {
                livereload: true
            }
        },
        markdown: {
            files: [
                'README.md'
            ],
            tasks: ['markdown']
        },
        tasks:  [ 'express:dev' ],
    },

    // debug while developing
    jshint: {
        all: ['Gruntfile.js', '<%= paths.assets %>/js/**/*.js']
    },
    concurrent: {
        dev: {
            tasks: ['nodemon', 'node-inspector', 'watch'],
            options: {
                logConcurrentOutput: true
            }
        }
    },
    nodemon: {
        dev: {
            script: 'server.js',
            options: {
                nodeArgs: ['--debug'],
                ext: 'js,html',
                callback: function (nodemon) {

                    nodemon.on('crash', function (event) {
                        console.log(event);
                    });


                },
                watch: _.union(defaultAssets.server.gruntConfig, defaultAssets.server.views, defaultAssets.server.allJS, defaultAssets.server.config)
            }
        }
    },
    forever: {
        server1: {
            options: {
                index: 'server.js',
                //logDir: 'logs'
            }
        }
    }
};

Angular controller function:

  $scope.addUser = function(){

      var user = {
          firstname: $scope.firstname,
          lastname: $scope.lastname,
          email: $scope.email,
          role: $scope.role.selected,
          password: $scope.password
      };

      $http.post('/api/userAdd', user ).then(function successCallback(response) {
          $location.path('/users');
      }, function errorCallback(response) {
          console.log('error addding user');
          console.log(response);
      });
  };

Express route:

User = require('../models/user.js');

module.exports = function (app) {

    app.get('/api/users', function (req, res) {

        User.find({}, function (err, users) {
            if ( err ) {
                res.send({
                    message : 'error finding users',
                    success: false
                });
            } else {
                res.json(users);
            }
        });

    });

    app.get('/api/users', function (req, res) {
        User.find({fields: {}}, function (err, docs) {
            res.json(docs);
        });
    });

    app.post('/api/userAdd', function (req, res) {

        var user = new User(req.body);

        user.save( function( err, user ){

            if (err){
                console.log('user.save error');
                console.log(err);
                res.send({
                    success: false
                });
            } else {
                console.log('user.save success');
                res.send({
                    success: true
                });
            }
        });

    });

};

I’m also testing with Chromes Advanced REST extension and with any request using this tool node crashes immediately.

I’m new to MEAN so am I missing something here that is causing the crash? Any ideas?

In this post, I will give you 5 solutions, If you are getting a «nodemon app crashed — waiting for file changes before starting» error while trying to start your server with nodemon. This error generally occurs due to multiple node processes are running in the background or some syntax error in your code.

Below mentioned are the errors, you may encounter during the nodemon server start process —

  • Nodemon app crashed
  • Nodemon app crashed — Waiting for file changes before starting
  • App crashed waiting for file changes
  • App crashed nodemon
  • Nodemon app crashed waiting for file changes

Following are the reasons for the above-mentioned errors:-

  1. Lot of node processess are running in background
  2. Package.json and server.js are not in the same folder
  3. Forgot to source your .env files
  4. Changed the file at the same time you save nodemon debugger working
  5. In case of MongoDB, issue with cluster

Let’s deep dive and see the solutions to fix the nodemon app crash issue.

I have jotted down 5 possible solutions for the nodemon app crashed issue for you. Try to follow all these solutions one by one, I am sure you will get your issue fixed.

Nodemon app crashed - Waiting for file changes before starting

Solution1 — Check and kill node processes to fix Nodemon app crashed issue

I am sharing options for Windows and Linux both. So based on your operating system, you can choose your steps.

For Linux —

  • Look for process id of node and make a note. This pid will be used as input in second command.
$ ps aux | grep -i node
  • Kill the process
$ sudo kill -9 [Process-ID]

or

$ sudo killall -9 node

Or you can also kill a specific port instead of killing all node processes

sudo lsof -i :3000 //replace 3000 with your port number
sudo kill -9 31363 // replace 31363 with your PID

For Windows

  • <Right click> on «Taskbar» and open Task manager
  • Check for the process Node.js: Server-side JavaScript in list
  • Select process and Click «End task» to kill node processes

It will fix the «Nodemon app crashed — Waiting for file changes before starting» error issue for sure.

Solution2 — Check for any JS syntax error in your code and run your server manually to debug error

Typing mistakes and JS syntax errors are the most common issues, which will stop your nodemon to start and will result in a nodemon app crashed error.

Once you validated that syntax is correct and there are no typing mistakes. Try running your server manually or use debug command to troubleshoot further.

  • Try Starting server manually
$ sudo node server.js

or

$ sudo node index.js

Run Nodemon server manually

  • Use debug option while running server
$ node --debug server.js

Solution3 — Validate Package.json and server.js are not in the same folder

To validate Package.json and server.js are not in the same folder. Open your Package.json file and check —

"scripts": {
    "test": "echo "Error: no test specified" && exit 1",
     "start": "nodemon Server.js"
 }

The below-mentioned image reflects the default entries in the package.json file after nodemon installation.

Package.json file default entries

Solution4 — Source your environment (.env) file

Don’t forget to source your environment variable file. Sometimes, if you forgot to source your «.env» file, that also results in the Nodemon app crashed — Waiting for file changes before starting» error. Check out this article for more information.

Solution5 — Validate MongoDB cluster is working fine

In the case of Mongo DB, make sure your cluster is working fine and restart your application. In addition, re-check for the mongo connection URL which was saved in default.json.

Summary

Above mentioned solutions fix approximately all nodemon crashed issues. If you follow all instructions carefully, I am confident, one of these solutions will fix your «Nodemon app crashed — Waiting for file changes before starting» error.

If you still get any issues, you can reply via comments and I will try to help you in the best possible way.

Happy Learning.

@xkeshav

@andrija-hers

There is a server that’s already running, so you cannot start another server.

MEADevloper, Kcin1993, Sharathnasa, JOELJOSEPHCHALAKUDY, zmm156, gjermundnor, eyeballss, vikas26294, cygnauh, jozistudio, and 111 more reacted with thumbs up emoji
wheeless, squallleonharts, glxck, trieu0479, imenBoukhris, rezamasrori, tomohiro-hack, mmetinn, midnightgamer, oroojtatiev, and 30 more reacted with thumbs down emoji
NPColdpage, eyeballss, nandes2062, felix9ia, sedkis, anatoliianatolich, adamklepacz, gnunua, Netrhil, squallleonharts, and 17 more reacted with laugh emoji
NPColdpage, eyeballss, Sanda91, adamklepacz, ismailkaratr, idontlikeyellow, squallleonharts, RodrigoPauletti, masterhero222, gaving, and 5 more reacted with hooray emoji
squallleonharts, SruthiSNair, sophialefevre, shivamg068, Proinfinto, MuhaddiMu, masterhero222, markmcsong, yaniaular, onejustone, and 6 more reacted with confused emoji
MEADevloper, adlondon, zmm156, gjermundnor, NPColdpage, eyeballss, fringlesinthestreet, adamklepacz, gnunua, rfracer, and 19 more reacted with heart emoji
squallleonharts, RodrigoPauletti, sashaey, masterhero222, genaromalpeli, gaving, nategiraudeau, alihejazi, TuanNguyen-A, agnese-kerubina, and BinhIT reacted with rocket emoji
squallleonharts, elissonmichael, susanka068, masterhero222, adberg2001, FErookie, mspreethi2001, albertcito, gaving, xetnopnawab, and 9 more reacted with eyes emoji

@CharcoalG

screenshot from 2015-05-27 11 17 15
on starting the $ nodemon server.js

What to do now?

prasath0908, Risyandi, Qwislet, hekichine, mohamedshames2001, and abhishekpratapsinghbeter reacted with thumbs up emoji
GAGANSWAMI789, Mostafasahim, and akhilc06 reacted with thumbs down emoji
buitu9x, Abidmuhammad999, ImaneTahri, and phandiem123 reacted with laugh emoji
MuhaddiMu, Gustavo160485, masterhero222, FErookie, mohammadshaban, buitu9x, Raj2609-coder, rtetala, ilyos-sheykh, Mostafasahim, and 3 more reacted with confused emoji

@gichuwil

Restart the server [Ctrl+C then nodemon server.js]

zmm156, unboundedimages, YNathaly, AydarF, alaamahasneh, nudge411, karunakarpatil, vedanthv, TranVanTu1209, Palak921, and 8 more reacted with thumbs up emoji
Nagenderpratap, shantanumadane237, thebkr7, EvgenijMerchansky, cuiyajie, sonampriya404, Mulli, AntiMoron, TucumanCompras, erkinover, and 190 more reacted with thumbs down emoji
MarcoPineda, vedanthv, omarkamelmostafa, Tarber, rodrifus, vchimania, yousefmasry4, mahfuz0498, fgunz07, and junaidz15 reacted with laugh emoji
djnorrisdev, ana-pau, sagartalla, rutuja-coder, hoangduyartist, vplvts, raghav-sodani, ShabdVeyyakula, knescobar, EDusik, and 6 more reacted with confused emoji
bouziani98mustafa, surajack12, alinbidirliu, and SavitaPrabha reacted with rocket emoji

@CharcoalG

hobofan, jarvisfosidck, cristian-eriomenco, prateekjahead, ohralathe, praneshkmr, RankWeis, an-dev, JOELJOSEPHCHALAKUDY, Alevale, and 81 more reacted with thumbs up emoji
KseniaKapnik, maximusnikulin, giiska, fmh093, zhilichaoA, jafetmorales, rafaelhdr, dibyn, GAGANSWAMI789, and cristianGzo reacted with thumbs down emoji
prabin04, dragan-rakita, tabufellin, diogosousa17, and AlexanderPershin reacted with laugh emoji

@sivasubramanianp

Check all things in render paths

EX:-
res.render

@sivasubramanianp

Reinstall all dependencies

$ npm install

ricardobandala, laurenceberry, toandev95, camilosanchez, joelgarza, is0sceles, puntgo, DannickBedard, immbudden, MarceloVarela, and 74 more reacted with thumbs up emoji
dzzonii, matheuscas, soniapatel, bakhtarov, MuthukumarHelios, dman777, Nagenderpratap, shantanumadane237, NPColdpage, EvgenijMerchansky, and 102 more reacted with thumbs down emoji
karthicksndr, gabrieldev525, Dohyun-98, qahta0, vchimania, CristianoFIlho, and houra49 reacted with laugh emoji
kedarSedai, syket-git, meru20, HyunwooJi-AIC, yawlad33, harshit860, hagiakiet-coder, and Ramesh244 reacted with hooray emoji
evglark, Abasahebshelvane, iAli22, Magamex, Yuri-Predborskiy, timmyLan, awwalfareed, donwilliams26, mmarioolive, dvilf, and 10 more reacted with confused emoji
saffiullah200, djnorrisdev, ezert, jy7123943, CodeIsa, andrenogueiramartins, kalavh, hwolf0610, hidaytrahman, SAMSALILY, and 3 more reacted with heart emoji

@VikramTiwari

gauravgupta799 reacted with thumbs up emoji
GAGANSWAMI789, techieshashwat, Ambitious156288, manu2504, Mostafasahim, sumicet, ChristianWilsonEtiaba, makpolat-cmd, Midrigan-Tudor, hamunna, and 16 more reacted with thumbs down emoji

@davidisaza21

GAGANSWAMI789, techieshashwat, Mostafasahim, ChristianWilsonEtiaba, Gesdra, IgnatG, rmRiteshMaurya, WonderBosst, wahmd, pavandoescode, and 2 more reacted with thumbs down emoji

@igorg1312

Thank you too. Fixed
Il 05 Mag 2016 23:36, «David Isaza» notifications@github.com ha scritto:

Thanks for the fix!


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#1066 (comment)

csilvers

added a commit
to Khan/react-render-server
that referenced
this issue

Jun 13, 2016

@csilvers

Summary:
We're seeing some errors where an instance can't be shut down cleanly
by google.  This is in the logs when that happens, according to
https://enterprise.google.com/supportcenter/managecases#Case/0016000000QWp9w/9115921
```
 app crashed - waiting for file changes before starting...
"FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory"
```

'waiting for file changes before starting' sure sounds like something
nodemon would say (linnovate/mean#1066
supports this).  My guess is google is killing the process, then
nodemon is trying to restart it, and trouble ensues.

So don't run nodemon, just depend on the normal google process for
monitoring health to do restarting when need be.

We still use nodemon in `dev` and `serve_local` modes because it's
super-useful there to notice file changes.

Test Plan: Fingers crossed

Reviewers: john, emily

Reviewed By: emily

Differential Revision: https://phabricator.khanacademy.org/D28109

@jingxingxingzhi

Hi, I encountered with the same problem. How do you fix it? Could you describe it in detail? Thanks a lot!

@camilosanchez

Thank you, I had the same problem, npm install fixed it

Sharathnasa, sonampriya404, polinazolotukhina, reshma-epsilon, angelikacheng, oroojtatiev, sajidahakther, corncobb, mbabazif, and Rb-wahid reacted with thumbs up emoji
Nagenderpratap, vikas26294, paxton4444, matijastampfel, kgonzalez452, Aleksanyanh, rodrigues327, timothylombrana, ujeneza, makkawysaleh, and 67 more reacted with thumbs down emoji

@Jipsian

I encountered with the same problem, but npm install didn’t fixed the problem (I tryed a lot of times).

serverpb.txt

mengayng, makkawysaleh, kevinjaypatel, Heitor458, llopes12, superneil6, HayleyLL, Daniyal857, vijaylakshmii, Nirupama654, and 15 more reacted with thumbs up emoji

@Aimanizales

Same fucking problem! Still happening after npm install. Nodemon piece of shit

VadimZP, thebkr7, dann1609, CaioIbraim, adrian-moisa, adamhrosenberg, kaaaata, ranwenqi, samwil, gvortel, and 117 more reacted with thumbs up emoji
cloud-tribal, samiraguiar, guanchor, InquisitivePenguin, bermanboris, agdolla, sarathjasrin, swyxio, karocksjoelee, noveogroup-amorgunov, and 62 more reacted with thumbs down emoji
byronsanchez, karlnoelle, hassenc, temurih, ignaciozhuzhu, krlsg, c0drut, xugy0926, marckuz, demirelfth, and 102 more reacted with laugh emoji
ShayanJavadi, Raja-Sharma, duanwent, geranim0, rmckeel, teffcode, Serozhka18, emeldincer, JoseAlbb, pignax, and 8 more reacted with confused emoji
KengoKato02 reacted with heart emoji
agung1204, DabblesWithApps, calumgunn, JoseAlbb, pignax, vidyashhraj55, eduardopelitti, AugustoAmaral, MuhammadimYusoff, iipragyaii, and 18 more reacted with eyes emoji

@timelf123

@Aimanizales please post the full error message you see, or we can’t really help you

@Jipsian that stack trace is not from meanio — the error says your local mongod is not running

@sp1d3rino

It could be that nodemon is using a server.js that try to connect with mongodb and if you don’t have mongod up and running then nodemon fails to start

InquisitivePenguin, artemypogosov, kalanaelapatha, Bobu-Work, Thandojelly, nvela031, alexvirdee, AlexGumenyuk, juniorlopez1, 1Kopal, and 2 more reacted with thumbs up emoji

@Hardik21

I want to it restart automatically after app crashed. I use nodemon in live project. so it is not possible every time to restart server.

@Shamel1

I am having the same problem.
image

andreobueno, sstruct, matijastampfel, supproduction, AksaMohammadi, jost-s, imVinayPandya, mstfa6060, Oseias447, ana-pau, and 34 more reacted with thumbs up emoji
agung1204, JoseAlbb, Jabavi18, satishyerramsetti, divesham, AS2017521upeksha, NikkenTriasa, grit-everything, saharlouati, MalikMati93, and 29 more reacted with hooray emoji
yashgour, JahedHossenBangladesh, Mohsin222, prakashkumarnks, chaithanyatt, caciano4, mohammed430, PushparajManickam, fouadAmine, cong201, and AdonayGarciaTrujillo reacted with confused emoji

@Shamel1

I need help..new to this.

@liorkesos

@praWINK

I am also having this same issue…anyone solved this issue???

@RayanaAlencar

Hi all,
I was with the same problem. The problem was that I forgot to start the mongo (sudo mongod) before run my server.

joonhyukchoi, wiki-doctor, brotzky, Em774, sstruct, teffcode, nadeemramsing, Geek-James, BurhanAmedie, vaishnavi4549, and kevinlin115 reacted with thumbs up emoji
simgooder, Saraamanda, Esmir-dev, VysochanskiyS, kevinlin115, and santhanamsv2786 reacted with hooray emoji

@Hardik21

Have you tried with PM2 plugin. This plugin is best solution ever. Once you start with this plugin, after then never required to start it again.

Have a look this link: PM2 npm

@kidkat

@Jipsian did you found how to fix the problem ? Please can you help me 2 ?

@shubhamduttasd

stiil now no solution for this??

@shubhamduttasd

screenshot from 2017-06-16 16-05-24

@shubhamduttasd

i am facing problem regarding this any solutn??

@timelf123

Upgrade your node version

shubhamduttasd, devwax, duduindo, PauloTC, AlineSantosx91-zz, lillastar824, and jrukit reacted with thumbs up emoji
ujeneza, sravan7755, Proinfinto, midnightgamer, fethan, mahisaajy, sdomenick, dannyhuly, dmackca, gaspar-d, and 7 more reacted with thumbs down emoji
PauloTC and ibrahimhlvaci reacted with rocket emoji

@SunShinewyf

I encountered with the same problem, but npm install didn’t fixed the problem and my mongodb is running , don’t know the reason.

@Panuruiz

If you are using MongoDB Atlas, check the «Network Access» in the Website. If you have a dynamic IP, you will have probably forbidden access to the cluster. Just configure your new IP Adress directly on the website, or configure it to allow acces from everywhere (not recommended).

@ParkMinsang

I solved same problem. I didn’t require. so I add require code and solved it.

@carlosAndress101

esta es la solución del problema hay que instalar bien babel…

{
«presets»: [
[
«@babel/preset-env»,
{
«targets»: {
«node»: true
}
}
]
]
}

@NouhaBHY

fixed for me :
ctrl+c
then i restart pc

@karim12345-gif

what about pkill? (to kill all node connections)

pkill node

pkill node worked for me, thanks !

@Shachi-Priya

«scripts»: {
«start»: «nodemon script.js»
}

here, after «nodemon» write file name which you want to run like I have written «script.js» in package.json.
I hope it will help you😊.

@Mostafasahim

I think you just need to check over your code. it worked for me i had some code mistakes… and now that i looked over my code
everything is fine!👍

@boamatule

If you are using mongodb create a new project on the Atlas mongoDb and use the new cluster’s mongoUri.
Save the file
Restart nodemon.
This worked for me.

Also nodemon app crash can also be caused by an error in your code especially semicolons(;)

True! For me was it! Thanks :)

@moezbenrebah

I got the same error, so the solution for me was grep all processes that node.js connect with, and then kill all these processes, restart my server, and voila everything went without error:
so on your terminal run this command:

netstat -lntp | grep node

your output will be something like that:

tcp        0      0 127.0.0.1:34919         0.0.0.0:*               LISTEN      14877/node          
tcp6       0      0 :::5000                 :::*                    LISTEN      15064/node          

and just using kill command + PID:

I hope that’s will help

@FazlanFarook

None of the solutio worked. Im still trying. Please update me if anyone have the latest solution

@karim12345-gif

None of the solutio worked. Im still trying. Please update me if anyone have the latest solution

did you try killing the server? …i had the same issue ,but using (pkill node) worked with me .. maybe you should check if you have any minor mistakes in the code or so !

hope this helps!

@xuanchinh97

@jose1574

hola…. estoy empezando a programar y estuve buscando un buen rato la solución, tenia un problema en mis rutas, me faltaba exportar en modulo para poder cargarlo en mi index.js espero le ayude a alguien.

@EIOTAFRICA

options retrywrites , w are not supported

@zamio1703

instale express
npm install express
y cambie el numero de puerto 3000 a 3001

@FazlanFarook

None of the solutio worked. Im still trying. Please update me if anyone have the latest solution

did you try killing the server? …i had the same issue ,but using (pkill node) worked with me .. maybe you should check if you have any minor mistakes in the code or so !

hope this helps!

thank you for your time, I had a memory issue

@yana1306137

Solve by change node / nvm with version 10.0.0

nvm install 10.0.0
nvm use 10.0.0
and running….

@HanPac

if you are using EJS, TypeScript and Node
npm install -g ts-node

@A1eeex

image

The error may be due to an incorrect format in postman.

@felipehimself

I had the same problem and the issue was I hadn’t imported a route correctly:

I was importing: ‘ import postRoutes from ‘./routes/posts’

I fixed it by importing including .js at the end:

import postRoutes from ‘./routes/posts.js’

@Vimal200

events.js:292
throw er; // Unhandled ‘error’ event
^

Error: listen EACCES: permission denied 2000;
at Server.setupListenHandle [as _listen2] (net.js:1301:21)
at listenInCluster (net.js:1366:12)
at Server.listen (net.js:1463:5)
at Function.listen (C:UsersAdminDesktopprojectmernbackendnode_modulesexpresslibapplication.js:618:24)
at Object. (C:UsersAdminDesktopprojectmernbackendsrcindex.server.js:7:5)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Emitted ‘error’ event on Server instance at:
at emitErrorNT (net.js:1345:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: ‘EACCES’,
errno: -4092,
syscall: ‘listen’,
address: ‘2000;’,
port: -1
}

Can any one help me in solving this problem…. I have tried everything as above but still I’m getting this error.

@anegri93

Hi, solved with:
npm i -g @babel/node -D

@helder-hanka

@helder-hanka

Hello everyone,
I did a test and created an error on my input line 9 of my Postman, to see how my server handles this,
but my app crash because of my express-valitor that I misplaced on my index.js.

if anyone can help me please.
Thanks in advance

@Stuti2803

image

Everytime I’m opening my server, I’m getting this error. Please someone help.

@Stuti2803

image

Everytime I’m opening my server, I’m getting this error. Please someone help.

image
This is my simple code. Please help out.

@Santhoshdevmj

screenshot from 2015-05-27 11 17 15 on starting the $ nodemon server.js

What to do now?

I got same when i’m run node application
apt install npm
apt-get update

use this command

@tiaabboudsync

@Ibrahim-krimi

Pour moi j ai juste tuer tous les processus Node avec pkill node et apres j ai relance le server et ça fonction mais apres ça depend parfois c est a cause de manque de mongoose ..

@TomsH1

I was dealing with this error for a few days, the compile time errors were not showing up and the only thing I was getting on the console is the nice message: _[nodemon] app crashed - waiting for file changes before starting..._ with no further details. In my case I corrected it by removing Type: «modules» from the package.json and using require, now I see the error detail in the console

Nodemon is not something new to the world of programming as it is one of the tools that are used to develop applications that are based on node.js. When using a nodemon, the node should be replaced with the nodemon in the command at the time of running the script. An error ‘[nodemon] app crashed – waiting for file changes before starting’ pops up when you are working on the nodemon.

This error seems annoying when you get it after executing a long script. Let’s have look at the error that you may get

When you are trying to execute a program using nodemon, you land yourself up in the error. This is how you get the error

Mongoose: users.insert({ firstname: 'firstname', lastname: 'lastname', email:'[email protected]', role: 'admin', password: 'nick', _id: ObjectId("57485c16fc11894b96c28356"), created: new Date("Thu, 13 Oct 2016 15:40:17 GMT"), __v: 0 }) 
 user.save success
 node crash
 [nodemon] app crashed - waiting for file changes before starting...

You can also get a browser console response like this:

http://localhost:8000/api/users net::ERR_CONNECTION_REFUSED

That’s how you experience the ‘[nodemon] app crashed – waiting for file changes before starting’ error.

Solutions to Fix the “[nodemon] app crashed – waiting for file changes before starting” Error

Check the solutions to get rid of the error

Solution 1 – Kill node process

The error occurs because of the server processes running in the background. To avoid the error, you have to close the terminal. Some programmers use Linux while many use Windows operating system. Let’s discuss see how you can solve the error

For Linux

When working with Linux, every time you get the error, you need to use the below command to close the terminal

Once done, you just need to restart the nodemon to make it work.

For Windows

If you are a Windows user, then you need to follow the below code

1. Go to the task manager
 2. Then look for Node.js: Server-side JavaScript
 3. Then right click on it and End task from the processes.

To make it work perfectly, you need to restart the nodemon.

This solution can fix the [nodemon] app crashed – waiting for file changes before starting’ error.

Solution 2 – the Package.json and server.js are not in the same folder

Make sure the Package.json and server.js are not in the same folder as it can cause the error warning. In order to check the file, follow the code

"scripts": {
    "test": "echo "Error: no test specified" && exit 1",
     "start": "nodemon Server.js"
 }

Solution 3 – Check for syntax error

The JavaScript syntax error or typing mistake can also be the reason you get an error when compiling. To solve the issue, you need to first check for the syntax by validating, and then to troubleshoot, use the command to debug or run the server manually.

For debugging

For running the server manually

$ sudo node server.js

or

$ sudo node index.js

Conclusion

And that’s how to tackle the [nodemon] app crashed – waiting for file changes before starting’ error.  I hope you find it useful!

I wish you all the best!

The nodemon app crashed waiting for file changes before starting and compromised your programming experience due to several running node JS processes. Due to this reason, your program shows the nodemon app crashed message and terminates the program, although the nodemon Daemon is fully functional and responsive.nodemon app crashed waiting for file changes before starting 1

However, you are at the best place to learn how to repair the nodemon app crashed – waiting for file changes before starting on Mac using the most simple yet effective debugging approaches and solutions.

In addition, this profound guide teaches how to recreate the nodemon restart without changes, which is essential before changing the elements and values in your nodemon app.

Contents

  • Why the Nodemon App Crashed Waiting for File Changes Before Starting?
    • – Multiple Active Server Processes in the Background
    • – Creating an Express Route With Angular Controller Functions
  • How To Fix the Nodemon App That Crashed Waiting for File Changes Bug?
    • – Ensure the JS Server and Package Files Are in the Same Folder
  • Conclusion

The nodemon app crashed – waiting for file changes before starting… VSCode due to multiple running node processes at the same time in the background. In addition, your system will encounter this broken exception when the JS package and server are not in the same folder.

For instance, the [nodemon] clean exit – waiting for changes before restart code exception is inevitable when running many node processes in the background. Henceforth, the app crashed, and your system failed to render the inputs regardless of how correct and clean your syntax looks.

Still, this is one of the many culprits for the docker nodemon app crashed – waiting for file changes before starting a warning, especially with complex applications. We also experienced this broken exception when the JS server and package are not in the same folder, confusing your program and displaying the error under consideration.

As a result, checking your document and structure is critical before completing the application to avoid unexpected obstacles and mistakes.

In addition, the bug can occur when forgetting to source your env files, confirming the port 3000 is already in use nodemon app crashed – waiting for file changes before starting.

However, we will reproduce the nodemon app crashed no error message to help you troubleshoot the program and pinpoint the failed procedures. Furthermore, you can compare the real-life examples to your document, which should help you locate the running code processes and commands.

– Multiple Active Server Processes in the Background

This guide’s first broken script runs an application using a JS node server on Mac. Although the procedure sounds straightforward and no mistakes should occur, the system experiences obstacles due to the active server processes in the background.

As a result, we will exemplify the terminal output and JS grunt file to confirm the inconsistencies.Nodemon App Crashed Waiting for File Changes Before Starting Causes

The following example provides the terminal output:

Mongoose: users.insert ({ firstname: ‘josh’, lastname: ‘lucas’, email:’josh@gmail.com’, role: ‘admin’, password: ‘josh’, _id: ObjectId (“57485c4198124h12857”), created: new Date (“Fri, 27 Dec 2022 14:13:18 GMT”), __v: 0 })

user.save success

node crash

[nodemon] app crashed while waiting for file changes before starting…

This code snippet confirms the flaws and terminates the program due to the running node processes. However, the example is only complete after providing the JS grunt file exporting the modules.

The following syntax provides this file:

module.exports = function(grunt) {

require(‘load-grunt-tasks’)(grunt);

var pkg = grunt.file.readJSON(‘package.json’);

var options = {

paths: {

app: ‘app’,

assets: ‘app/assets’,

dist: ‘app/dist’,

distAssets: ‘app/dist/assets’,

html: ‘app/html’,

htmlTmp: ‘.tmp/htmlsnapshot’,

htmlAssets: ‘app/html/assets’,

index: ‘app/dist/index.html’,

indexDev: ‘app/index.html’,

indexTmp: ‘.tmp/html/index.html’

},

pkg: pkg,

env: {

test: {

NODE_ENV: ‘test’

},

}

};

var configs = require(‘load-grunt-configs’)(grunt, options);

grunt.initConfig(configs);

grunt.task.registerTask(‘mongoose’, ‘Task that connects to the MongoDB instance and loads the application models.’, function () {

var done = this.async();

var mongoose = require(‘./config/lib/mongoose.js’);

mongoose.connect(function (db) {

done();

});

});

grunt.registerTask(‘bumper’, [‘bump-only’]);

grunt.registerTask(‘css’, [‘sass’]);

grunt.registerTask(‘default’, [

‘copy:dev’,

‘mongoose’

]);

grunt.registerTask(‘shared’, [

‘clean:demo’,

‘ngconstant’,

‘usebanner’

]);

grunt.registerTask(‘demo’, [

‘copy:postusemin’,

‘grep:demo’

]);

grunt.registerTask(‘dist’, [

‘copy:postusemin’,

‘grep:demo’,

]);

grunt.loadNpmTasks(‘grunt-forever’);

};

Still, this is one of the many examples of forcing your system to fail.

– Creating an Express Route With Angular Controller Functions

Due to the active server processes, we can recreate the error log when creating an express route with Angular controller functions.

Although this instance rarely affects advanced projects and applications, it can happen when you expect the least. Therefore, we will exemplify the express route and Angular controller functions to capture the error’s root.

The following example provides the express route:

User = require (‘../models/user.js’);

module.exports = function (app) {

app.get (‘/api/users’, function (req, res) {

User.find ({}, function (err, users) {

if ( err ) {

res.send({

message : ‘error finding users’,

success: false

});

} else {

res.json (users);

}

});

});

app.get (‘/api/users’, function (req, res) {

User.find ({fields: {}}, function (err, docs) {

res.json (docs);

});

});

app.post (‘/api/userAdd’, function (req, res) {

var user = new User (req.body);

user.save ( function ( err, user ){

if (err){

console.log (‘user.save error’);

console.log(err);

res.send({

success: false

});

} else {

console.log (‘user.save success’);

res.send({

success: true

});

}

});

});

};

Although most functions and commands appear functional, the system displays an exception. However, we can complete the invalid procedure by exemplifying the Angular script, as shown in the following example:

$scope.addUser = function(){

var user = {

firstname: $scope.firstname,

lastname: $scope.lastname,

email: $scope.email,

role: $scope.role.selected,

password: $scope.password

};

$http.post (‘/api/userAdd’, user ) .then (function successCallback (response) {

$location.path (‘/users’);

}, function errorCallback (response) {

console.log (‘error addding user’);

console.log (response);

});

};

Remember to compare the processes to your document to troubleshoot the program and locate the broken procedures. This also helps with the debugging methods, as you will soon learn.

How To Fix the Nodemon App That Crashed Waiting for File Changes Bug?

You can fix the nodemon app that crashes code exceptions by checking and shutting down all irrelevant running node processes. In addition, you can overcome the error log by ensuring the JS package and server files are in the same folder, which is critical for your program.

This section confirms the debugging approaches only take a minute to implement and do not affect other functions and elements. In addition, they work for all applications regardless of commands and processes.

Considering that, we will teach you how to check and kill the irrelevant running node processes. The debugging steps differ for Linux and Windows, so we will cover both.

The following list debugs your Linux operating system:

  1. Search for id node processes and take note. Use the following command line to start the procedure: $ ps aux | grep -i node
  2. You must use this command to shut down the irrelevant running processes: $ sudo kill -9 [Process-ID]
  3. Alternatively, use the following method to kill specific ports: sudo lsof -i :3000 //replace 3000 with your port number, and sudo kill -9 31363 // replace 31363 with your PID

This solution works for all Linux systems, and you should avoid severe obstacles. Still, use the following list to repair your Windows project:

  1. Open the Task Manager by clicking the taskbar.
  2. Check the list for these processes: Node.js: Server-side JavaScript.
  3. Select the procedure and click the End Task option on the right.

Your program should no longer experience this mistake when making changes to the script.

– Ensure the JS Server and Package Files Are in the Same Folder

The second debugging approach suggests checking if the JS server and package files are in the same folder. This removes the code exception and reenables all procedures in your application.Ensure the JS Server and Package Files Are in the Same Folder

Use the following code snippet to check both files:

“scripts”: {

“test”: “echo ”Error: no test specified” && exit 1″,

“start”: “nodemon Server.js”

}

So, your system should indicate the packages are in the same folder by displaying the following visual output:

dev@dev-ubuntu-2245: $ more /home/ dev/ package.json

{

“dependencies”: {

“server”: “^1.0.37”

}

}

dev@dev-ubuntu-2245: -$

Your system should no longer experience this code exception after placing the JS server and package files in the same folder.

Conclusion

The nodemon app crashed while waiting for file changes before starting and compromises your programming experience due to several running node JS processes. You can remember this guide’s critical points in the following bullet list:

  • The error can happen when the JS package and server are not in the same folder
  • We recreated the mistake by running an application using a JS node server on Mac
  • Checking and shutting down all irrelevant running node processes is the first solution
  • Both debugging techniques from this guide fix all applications regardless of the purpose

This step-by-step guide proved that repairing your program and removing the nodemon exception is simple and takes little time. So, open your program and implement these methods without further ado.

  • Author
  • Recent Posts

Position is Everything

Your Go-To Resource for Learn & Build: CSS,JavaScript,HTML,PHP,C++ and MYSQL. Meet The Team

Position is Everything

Понравилась статья? Поделить с друзьями:

Не пропустите также:

  • Как составить проект младшему школьнику
  • Как найти папку корня диска
  • Как исправить с помощью консоли
  • Sata cd tsstcorp cddvdw sn 208bb как исправить
  • Как исправить поверхность жесткого диска

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии