Nodemon没有重新加载.这个nodemon.json文件有什么问题

VsM*_*MaX 13 node.js typescript nodemon

这是我的nodemon.json

{ 
    "watch": ["src/**/*.ts"],
    "exec": "node out/index.js" 
}
Run Code Online (Sandbox Code Playgroud)

我通过执行以下命令来运行nodemon:

nodemon
Run Code Online (Sandbox Code Playgroud)

在root nodejs目录中

这是输出:

 % nodemon                                                                                                     
[nodemon] 1.11.0                                                                                
[nodemon] to restart at any time, enter `rs`                                                                                                                       
[nodemon] watching: src/**/*.ts                                                                                                                       
[nodemon] starting node out/index.js
Yay! Started app!
Run Code Online (Sandbox Code Playgroud)

但是当我在src中编辑任何ts文件时,nodemon不会重启应用程序.

UPDATE

运行 nodemon --watch src/index.ts --exec 'node out/index.js'

在修改index.ts时运行并重新加载应用程序

但是,使用通配符运行

nodemon --watch 'src/**/*.ts' --exec 'node out/index.js'

要么

nodemon --watch src --exec 'node out/index.js'

不重新加载应用程序.

VsM*_*MaX 28

解决了!

通过以详细模式运行nodemon,我发现默认情况下它只监视*.js文件,无论您正在观看哪个通配符.因此,添加-e ts到该命令可以解决问题:

nodemon --watch src/ --exec 'node out/index.js' -e ts
Run Code Online (Sandbox Code Playgroud)

如果有人nodemon.json在这里使用我的修复后是我的:

{ 
    "watch": ["src"],
    "exec": "tsc && node out/index.js" ,
    "ext": "js json ts proto"
}
Run Code Online (Sandbox Code Playgroud)