I have two applications which I want to run on two different ports. I am using webpack to bundle all my static contents in a dist folder and running the static-server. static-server default runs on 9080 and the first application runs perfectly fine. However, when I try to run the second application, I get an error that port is already in use. So I am setting a new PORT for another application so that it serves on that port. To do so, I am doing something like below. In my package.json-
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --hot --config webpack.prod.js",
"build": "webpack --config webpack.prod.js",
"start:prod": "set PORT=3006 && cd dist && static-server"
}
I am not able to set the port to 3006 and instead when I try to run status-server inside list folder, I get an error-
* Shutting down server
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::9080
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at Server.listen (net.js:1476:7)
at StaticServer.start (/usr/local/lib/node_modules/static-server/server.js:114:58)
at Object.<anonymous> (/usr/local/lib/node_modules/static-server/bin/static-server.js:48:8)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
I also tried to set port in my webpack.config.js inside deserver but still getting the same issue. Can someone please let me know what I am doing wrong.
PORT=3006 static-server ./diststatic-server -p 3306