On Server startup exporting 2GB(Approximately) data from mongodb to redis,then getting error as FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of mem
one option: npm start scripts
https://docs.npmjs.com/misc/scripts
These are added to your package.json under the "scripts" section
{
//other package.json stuff
"scripts":{
"start": "node --max-old-space-size=4076 server.js"
}
}
then to run it call npm start
instead of typing in node + args + execution point.
Note: if you name it something other than start, npm run [yourScriptNameHere]
will be the command to run it
This is a better option than trying to reconfigure node to use 4gb by default (don't even know if its possible tbh). It makes your configuration portable by using the baked in methods as it stands and allows others who encounter your code in the future to understand this is a need.