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.