I use the "main" parameter in my package.json file to indicate the startup script. There are times however when I need to change the script to be a different file. I don't really like having to edit the main parameter because sometimes I forget to set it back to what it originally was. If I could run npm start
and include some optional parameter to set the main parameter that would be great. Is that possible?
Asked
Active
Viewed 97 times
0

Johann
- 27,536
- 39
- 165
- 279
-
Could you use something like [this](https://stackoverflow.com/questions/22646996/how-do-i-run-a-node-js-script-from-within-another-node-js-script) to start a certain JS file from a central main file? – Luca Kiebel Sep 04 '18 at 15:50
-
I haven't tried with `npm start`, but it's possible to add additional parameters to `npm run xyz` calls: https://stackoverflow.com/questions/11580961/sending-command-line-arguments-to-npm-script maybe it works with npm start as well? – Capricorn Sep 04 '18 at 16:03