Search code examples
node.jsnpmweb-hostinghttpserver

http-server not stopping server when using Ctrl+C


I am using a simple npm module http-server https://www.npmjs.com/package/http-server to server static website. This is my package json

{
 "name": "dashboard-ng-starfleet",
 "version": "1.0.0",
 "description": "",
 "main": "index.js",
 "scripts": {
 "test": "echo \"Error: no test specified\" && exit 1",
  "start":"./node_modules/http-server/bin/http-server  -p=8080"
 },
 "repository": {
  "type": "git",
  "url": ""
  },
 "author": "",
 "license": "ISC",
 "homepage": "",
  "devDependencies": {
"http-server": "^0.10.0"

} }

Server starts once but once i stop it using Ctrl+C in terminal and again start server, it says Address already in use. Ideally it should have stopped.

Any help ?


Solution

  • Your start script should be

    "start":"./node_modules/http-server/bin/http-server  -p 8080"