1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Auto Reload for Node server and Web Browser Refresh using Nodemon

Discussão em 'Angular' iniciado por Shane D'Silva, Setembro 16, 2024.

  1. I'm trying to use Nodemon to auto reload my server and as a result, refresh my browser whenever I make a change to a JSON or JS file.

    My Web Server is located in directory 1 and my content with some JS, JSON, Angular and HTML files are in directory 2 for easier separation.

    I installed Nodemon as I saw somewhere that it auto reloads the server whenever there's a change in the directory of my app.js file which is in location 1 (web server).

    When I make a change to a JSON file in my content directory, the log in the terminal suggests that Nodemon is auto reloading the server but when I refresh my browser, the changes don't reflect and I have to manually restart the server to see them.

    I created a nodemon.json file in my web server directory which didn't seem to solve my issue either:

    {
    "restartable": "rs",
    "ignore": [
    ".git",
    "node_modules/**/node_modules"
    ],
    "verbose": true,
    "watch": [
    "/Users/shaned/repos/backend/server", //list of files, you want to watch for changes
    "/Users/shaned/repos/frontend/content"
    ],
    "ext": "js json html"
    }


    Also, I get this error after awhile:

    FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory


    This is how I run the server in the CLI:

    NODE_PATH=$SERVER nodemon $SERVER/backend/app.js --conf $TEST_ROOT/default.conf --test:geoip:code ""


    The web site currently works on Angular with Node v10.24.1 with NPM v6.14.12. I also work on MacOS so if there's an alternative package or solution, I'm open to suggestions.

    Continue reading...

Compartilhe esta Página