以下是我的文件:
package.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"
}tsconfig.json
{
"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"]
}当我做任何更改时,我会得到一个小的弹出窗口,但它实际上不会重新启动服务器,不确定我在这里做错了什么。
注意:当我第一次在服务器手动重启后进行更改时,它在终端[INFO] 22:07:09 Restarting: src/analytics-engine.ts has been modified中显示了一个弹出窗口和类似这样的内容,之后没有检测到任何更改。
发布于 2020-06-18 18:31:15
现在问题已经解决了。我使用--debug发现了这个问题,这是一个与'SIGTERM‘相关的错误。因此,我在npm start脚本中添加了一个标志--exit-child。
发布于 2021-09-25 05:49:19
--exit-child也为我工作过。
package.json中的示例
"scripts": {
"start": "ts-node-dev --respawn --transpile-only --exit-child --watch src src/index.ts"
},发布于 2021-01-08 11:47:25
我有类似的东西,使用ts-node-dev和pino。
当服务器启动时,会有一些日志记录到输出服务器的初始化进程。当开发服务器通过ts-node-dev重启时,有时它会输出write: EPIPE错误,因为我假设重启的服务器试图写入旧的流。
--exit-child标志似乎已经解决了这个问题
https://stackoverflow.com/questions/62434261
复制相似问题