nodemon not working properly

后端 未结 13 674
长发绾君心
长发绾君心 2021-02-01 05:18

I am running my nodejs app by npm start

I just installed nodemon by sudo npm install -g nodemon so that i can get my server restarted when i s

相关标签:
13条回答
  • 2021-02-01 05:33

    Here's what I did to make nodemon update correctly:

    nodemon index.js -L
    

    The -L flag stands for legacyWatch, here's an explanation from the official doc:

    In some networked environments (such as a container running nodemon reading across a mounted drive), you will need to use the legacyWatch: true which enables Chokidar's polling.

    https://www.npmjs.com/package/nodemon#application-isnt-restarting

    0 讨论(0)
  • 2021-02-01 05:39

    Certain child processes related to your parent process may not be closed. Try to kill all the child processes.

    Ref: https://github.com/remy/pstree

    0 讨论(0)
  • 2021-02-01 05:47

    Add following code in your code

    1. app.js

      app.listen(3000, function(){
          console.log("info",'Server is running at port : ' + 3000);
      });
      
    2. package.json

      nodemon app.js 
      

    Then run npm start from the command line.

    0 讨论(0)
  • 2021-02-01 05:48

    For Express 4; Just run

    nodemon

    command (with out any args) on the directory; this works for me.

    0 讨论(0)
  • 2021-02-01 05:48

    You might also run into the issue of having an empty .nodemonignore.

    0 讨论(0)
  • 2021-02-01 05:49

    You're running express 4, which has the app.listen call in a different file than app.js. The command you're looking for is nodemon bin/www (localhost and 3000 are not needed in this scenario).

    In fact, you can even run nodemon with no args, and it'll read what command needs to be run from scripts.start in package.json (which express generates automatically).

    0 讨论(0)
提交回复
热议问题