I want to start my index.js file with node --max-old-space-size=1024 index.js but I don't want to type the command manually everytime, any Idea how can I make a .js file that executes the command for me? Like start.js and when I launch it, it immediately runs node --max-old-space-size=1024 index.js. This might be super straight forward but I'm still new to node.js 😅
-
1You could spawn your "worker" node process, from a "starter" node process if you dont want so use a package scribt as J.F. answered. Use for that the node "child_process" module.Marc– Marc2021-10-28 18:15:36 +00:00Commented Oct 28, 2021 at 18:15
Add a comment
|
1 Answer
You can modify your package.json to create a command that execute node --max-old-space-size=1024 index.js
In your package.json
"scripts": {
"start": "node --max-old-space-size=1024 index.js"
}
And then run npm run start.
3 Comments
Karim Walid
Can't I make it an independent
.js file?Karim Walid
Like without using command line just click it and it executes the other command right away
J.F.
As far as I know, if you want to add parameters
--max-old-space-size=1024 you will need to add into the call for the other JS file. You can do a file start.js where exists the line require('./index.js') but your parameter (--max-old-space-size=1024) will be necessary to run start.js too. So is a better way use package.json I think.