I am building an nodeapplication, it has 3 environments names are development,testing and production. Each environment has their own hostnames and port numbers. like in the following way
{
"development":{
"host":"develop.com",
"port":"2000"
},
"testing":{
"host":"testing.com",
"port":"2001"
},
"production":{
"host":"production.com",
"port":"2002"
}
}
While running my node application, I used to pass environment name as a command argument. like
node server.js development
(or)
node server.js production
Instead of running application manually along with environment name, I want to implement with node scripts, so I have tried in the following way.
package.json
{
"developemnt":"node server.js development",
"production":"node server.js production",
"testing":"node server.js testing"
}
What I thought, Instead of node server.js development, I can run npm development. This way I have made it, but it's not working. Regarding this, I have read npm script documentaion, as per documentation It's not possible,so is there any way to implement this.
Thanks
For scripts that are not "default scripts" (the ones listed here), you need to use the run parameter with npm:
npm run development
npm run testing
npm run production
More details here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With