更改后 ts-node-dev 不会重新启动

Him*_*tia 5 node.js typescript tsc nodemon ts-node

这是我的文件:

包.json :

"scripts": {
  "generate-interfaces": "ts-node src/cli/generate-interfaces.ts",
  "dist": "npm run generate-interfaces && rm -rf dist && tsc && cp -r static/ dist/ && cp -r resource/ dist/",
  "prestart": "npm run generate-interfaces",
  "start": "ts-node-dev --respawn --transpileOnly --no-notify ./src/index.ts",
  "start:inspect": "ts-node-dev --no-deps --inspect -- ./src/index.ts",
  "pretest": "npm run generate-interfaces",
  "test": "jest"
 }
Run Code Online (Sandbox Code Playgroud)

配置文件

{
"compilerOptions": {
"declaration": true,
"target": "es2017",
"module": "commonjs",
"esModuleInterop": true,
"outDir": "dist",
"sourceMap": true,
"skipLibCheck": true,
"typeRoots": ["node_modules/@types", "./typings", "node_modules/**/*.d.ts"],
"lib": ["esnext"]
},
"include": ["src/**/*.ts", "./typings/**/*.d.ts"],
"exclude": ["node_modules/**", "dist"]
}
Run Code Online (Sandbox Code Playgroud)

当我进行任何更改时,我会看到一个小弹出窗口,但它实际上并没有重新启动服务器,不确定我在这里做错了什么。

注意:我第一次在服务器手动重启后进行更改时,它会在终端中显示一个弹出窗口和类似的内容,[INFO] 22:07:09 Restarting: src/analytics-engine.ts has been modified之后没有更改检测。

Mic*_*ael 20

--exit-child也为我工作过。

示例中package.json

"scripts": {
        "start": "ts-node-dev --respawn --transpile-only --exit-child --watch src src/index.ts"
    },
Run Code Online (Sandbox Code Playgroud)


Him*_*tia 13

现在问题已解决。我发现问题--debug是与“SIGTERM”相关的错误。所以我--exit-child在我的npm start脚本中添加了一个标志。