使用 Typescript 编译运行 Nodemon? [英] Run Nodemon with Typescript compiling?

查看:82
本文介绍了使用 Typescript 编译运行 Nodemon?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在使用命令 tsc 保存的每个文件上编译我的打字稿文件.

I want my typescript files to be compiled on every file saving with the command tsc.

如何将 tsc 命令与 nodemon 在 build:live 脚本中运行的命令结合

How do I combine the tsc command with the command that nodemon runs in the build:live script

"scripts": {
    "start": "npm run build:live",
    "build:live": "nodemon --watch '*.ts' --exec 'ts-node' app.ts",
 }

这个脚本会导致 nodemon 调用自己两次或三次:

this script causes nodemon to call itself twice or three times:

"build:live": "nodemon --watch '*.ts' --exec 'ts-node app.ts & tsc'",

推荐答案

这看起来会实现你想要的:

This looks like it will achieve what you're looking for:

"start": "tsc-watch --project . --outDir ./dist --onSuccess \"nodemon ./dist/bin/www.js\""

来源:https://github.com/Microsoft/TypeScript/issues/12996#issuecomment-349277673

这篇关于使用 Typescript 编译运行 Nodemon?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆