nodemon "restarting due to changes..." 在 VSCode 中重复显示并减慢每个重新启动进程

nodemon "restarting due to changes..." repeatedly displays in VSCode and slows down every restarting process

我使用 nodemon 版本 1.18.9(截至今天的最新版本)。

我使用 Visual Studio 代码 (VSCode)。我打开一个终端并执行 nodemon dev-server.js 但它反复显示

restarting due to changes...

如下

几秒钟后它将完成重启过程。

我用Windows10.

有什么建议吗?

我想您必须更改 VSCode 上的设置,转到“文件”->“自动保存”(取消选中该选项)。之后只有在指定路径下按ctrl+s才会重启项目


编辑:我在我的电脑上做了一些测试,我重现了你的意思,可能你正在尝试使用 nodemon 不支持的不同扩展。 看看这部分 documentation:

Specifying extension watch list By default, nodemon looks for files with the .js, .mjs, .coffee, .litcoffee, and .json extensions. If you use the --exec option and monitor app.py nodemon will monitor files with the extension of .py. However, you can specify your own list with the -e (or --ext) switch like so:

nodemon -e js,jade Now nodemon will restart on any changes to files in the directory (or subdirectories) with the extensions .js, .jade.

尝试运行nodemon -e ts,json(all extensions that you want to be listener) dev-server.js。当我删除扩展程序时,我遇到了同样的问题。

package.json

   {
      "scripts": {
        "nodemon": "nodemon dev-server.js"
      },
    }

通过 npm 启动 nodemon

$ npm run nodemon
save dev-server.js file, nodemon will restart twice

直接启动nodemon

$ nodemon dev-server.js
save dev-server.js file, nodemon is all right

osx 10.11.3
nodemon 1.9.2

=============来自评论的更新答案======================

更新评论中的答案,因为评论中的逻辑适用于此问题。

尝试添加延迟一段时间。让我知道它是否有效。 nodemon lib/dev-server.js --delay 1 ..

无论您的目录是什么。

  1. 尝试在不使用 nodemon 的情况下构建您的应用程序
  2. 更正错误,这可能是 tslint 无法修复某些内容并生成语法错误的结果
  3. 使用 nodemon 重新启动您的应用程序

请设置Windows环境路径

  1. 右键单击 PC/My 计算机
  2. 属性
  3. 环境
  4. 路径 --> 编辑 --> 新建
  5. 粘贴:- C:\Windows\System32

还行 然后重启VSCode