无法在使用 Typescript 构建的节点项目中运行 Nodemon(在 Windows 中)

Jim*_*val 5 build node.js typescript nodemon server

Node 项目是用Typescript构建的,package.json 文件中有三个脚本,但是当我运行它时显示......

如果我在ubuntu 中运行这个项目,它可以正常工作,但不能在Windows 中运行

输出端子图

但是在这个nodemon之后没有开始运行项目。

Package.json 中的脚本

"start": "tsc --watch & nodemon dist/index.js",
"lint": "tslint -c tslint.json 'src/**/*.ts' --fix",
"build": "tsc"
Run Code Online (Sandbox Code Playgroud)

帮我解决这个问题,提前谢谢你:)

Ale*_*sky 6

您似乎&tsc --watch和之间缺少一个字符nodemon dist/index.js。single&不是有效的and运算符:

"start": "tsc --watch && nodemon dist/index.js",
Run Code Online (Sandbox Code Playgroud)

更新问题似乎出在 Windows 上。通常这个问题是通过使用诸如并发或跨环境之类的库在 Windows 上以类似的方式执行命令来解决的。并发安装后:

"start": "concurrently \"tsc --watch\" \"nodemon dist/index.js\"",
Run Code Online (Sandbox Code Playgroud)

希望这有帮助!