Node.js 我需要一个脚本来结合 tsc build watch 和 nodemon

问题描述 投票:0回答:1

我目前有两个脚本:

"scripts": {
    "build": "tsc -p . -w",
    "watchjs": "nodemon dist/index.js"
}

我需要两个终端,一个用于构建 watchjs,我想将这两个脚本组合成一个脚本,以便在检测到更改后自动构建并在构建后运行它!

我试过类似的东西:

"start": "tsc -p . -w && node dist/index.js",

但显然

tsc -w

永无止境,因此我不能在构建完成后直接调用命令!

node.js typescript package.json npm-scripts npm-start
1个回答
0
投票

假设您的系统是 Windows(对于以下解决方案,您需要 concurrently 包作为 devDependency)

    "serve": "concurrently \"tsc -w\" \"nodemon dist/index.js\""

祝你好运!

© www.soinside.com 2019 - 2024. All rights reserved.