使用json-server + create-react-app

时间:2018-06-27 01:03:19

标签: node.js npm-scripts

我有一个示例反应应用程序,我一直在用它来构建一些小的辅助项目。但是我遇到了一个难题。 Ctrl+C并没有采取任何措施来停止我的应用。我必须手动通过任务管理器才能杀死它。我已经附上我的包裹json。是否有一些解决方案或方法?

{
  "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 个答案:

答案 0 :(得分:0)

也许尝试编写npm停止脚本?

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

希望有帮助