Unable to get TypeScript watching my project and nodemon reloading it

孤街醉人 提交于 2019-12-06 13:21:39

Adding a delay of 1000ms to nodemon fixed the issue for me.

https://github.com/remy/nodemon#delaying-restarting

nodemon.json

{
  "watch": ["build"],
  "ext": "js",
  "exec": "npm start",
  "delay": 1000
}

package.json

{
  "name": "demo",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node build/index.js",
    "ts": "tsc -w",
    "nodemon": "nodemon",
    "code": "concurrently -n ts,nodemon npm:ts npm:nodemon"
  },
  "devDependencies": {
    "concurrently": "^4.1.0",
    "nodemon": "^1.18.9",
    "typescript": "^3.2.2"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es2017",
    "noImplicitAny": true,
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "build",
    "baseUrl": ".",
    "paths": {
      "*": [
        "node_modules/*",
        "src/types/*"
      ]
    }
  },
  "include": [
    "src/**/*"
  ]
}

npm run code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!