I have some scripts in my package.json
, and I need to know how to get the start
script to correctly accept the -port
parameter for angular-cli.
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
We need this because we would like to run multiple instances of our software simultaneously. Currently, if I have one project running on the default port 4200, and try to run npm start -port 4300
in a second terminal window, I get, "Port 4200 is already in use. Use '--port' to specify a different port."
What can I do to get my build to run in a particular port? And how can I make it so that I can pass the port number into the npm start script from the command line?
The next time you run the npm start command, the default port used will be 7200 .
npm start runs an arbitrary command specified in the package's "start" property of its "scripts" object. If no "start" property is specified on the "scripts" object, it will run node server. js. It seems like ng serve starts the embedded server whereas npm start starts the Node servers.
If you add "--" the parameters are passed through:
npm start -- --port 4301
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