node.js - nodemon 在 Windows 上通过 npm 脚本启动时不观看
问题描述
我尝试在 Windows 上通过 npm 脚本运行 nodemon。起初我在命令提示符下运行脚本字符串。
./node_modules/.bin/nodemon -e ts --watch 'src/' --exec "npm run compile-component && node dist/index.js"
它可以正常工作。我更改文件夹中的文件,nodemon 监视它并重新启动服务器。但是当我尝试用 npm 运行它时,nodemon 启动了。当我在下面启动脚本时,您可以看到日志。
PS D:\Projects\my-project> npm run dev
> my-project@1.0.0 dev D:\Projects\my-project
> nodemon -e ts --watch 'src/' --exec "npm run compile-component && node dist/index.js"
[nodemon] 2.0.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): 'src\'
[nodemon] watching extensions: ts
[nodemon] starting `npm run compile-component && node dist/index.js`
> my-project@1.0.0 compile-component D:\Projects\my-project
> tsc -p tsconfig.json
App is listening on port 3000
但是当我更改文件时,nodemon 不会对它做出反应。我不明白为什么会这样。我该如何解决这个问题?
package.json
文件如下所示。
{
"name": "my-project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
...
},
"devDependencies": {
...
},
"scripts": {
"compile-component": "tsc -p tsconfig.json",
"dev": "./node_modules/.bin/nodemon -e ts --watch 'src/' --exec \"npm run compile-component && node dist/index.js\""
},
"keywords": [],
"author": "",
"license": "ISC"
}
解决方案
推荐阅读
- java - ubuntu 上的 Java 模块路径命令
- firebase - Firebase 函数读取和写入 Firebase 实时数据库是否有助于 Firebase 实时下载?
- javascript - 如何让我的代码为用户授权和许可生成 JWT 令牌?
- mysql - 如何将txt文件中的数据导入mysql数据库
- regex - 如何使用 Notepad++(或类似工具)批量查找代码
- linux - 如何在 Linux 中评估 TCP 变体
- rest - 从 REST API 响应下载数据,但响应代码为 -1
- python - 通过按小时和天分组来绘制时间序列数据
- laravel - 使用 laravel 向 whatsapp 发送消息和文件
- vue.js - 如何在 src 子目录的 bootstrap-vue b-card-img 中显示图像