我希望在使用命令 tsc
保存的每个文件上编译我的 typescript 文件。
如何将 tsc 命令与 nodemon 在 build:live
脚本中运行的命令结合起来
"scripts": {
"start": "npm run build:live",
"build:live": "nodemon --watch '*.ts' --exec 'ts-node' app.ts",
}
此脚本导致 nodemon 调用自身两次或三次:
"build:live": "nodemon --watch '*.ts' --exec 'ts-node app.ts & tsc'",
最佳答案
Nodemon 现在将自动检测并运行带有 ts-node
的 .ts
文件。它实际上也会运行带有 python 和 ruby 的 .py
和 .rb
文件,顺便说一句,您可以为其他人提供自定义的 --exec
。这是一个 link to the relevant code在 nodemon 中。
所以下面应该没问题:
"scripts": {
"dev": "nodemon app.ts"
}
关于javascript - 使用 Typescript 编译运行 Nodemon?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57998762/