0

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 😅

1
  • 1
    You 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. Commented Oct 28, 2021 at 18:15

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Can't I make it an independent .js file?
Like without using command line just click it and it executes the other command right away
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.