Node JS does not stop server with Ctrl+C when using json-server + create-react-app

2.5k views Asked by At

I've got a sample react app I've been messing with to build out little small side projects. But I've hit a connundrum. Ctrl+C doesn't do anything to stop my app. I have to go through task manager manually to kill it. I've attached my package json. Is there some package or approach for this?

{
  "name": "practice-app",
  "description": "Sample react app to practice different designs, tools and concepts",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^1.2.2",
    "@material-ui/icons": "^1.1.0",
    "concurrently": "^3.6.0",
    "json-server": "^0.14.0",
    "react": "^16.4.1",
    "react-dom": "^16.4.1",
    "react-scripts": "1.1.4"
  },
  "scripts": {
    "start": "concurrently \"react-scripts start\" \"json-server --watch data/db.json --port 3001\"",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "proxy": "http://localhost:3001"
}
1

There are 1 answers

4
sjdm On

maybe try writing an npm stop script?

"scripts": {
    "start": "app.js",
    "stop": "pkill --signal SIGINT myApp"
}

Hope that helps