gpt4 book ai didi

node.js - 修改html文件时Nodemon不会重新启动

转载 作者:IT老高 更新时间:2023-10-28 23:07:02 26 4
gpt4 key购买 nike

我正在学习Node.js,我的demo有两个文件:

  • /server.js
  • /public/index.html

/server.js将获得 /public/index.html然后返回给客户端。

我想使用 nodemon/public/index.html 时自动重新加载被修改。但是,似乎 nodemon仅在我修改 /server.js 时有效而不是当/public/index.html已修改。

我正在使用 nodemon server.js启动服务器。

最佳答案

只需在 nodemon 命令行上指定观看 html(或者更好的是,添加一个配置文件)。

来自 documentation :

By default, nodemon looks for files with the .js, .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.

关于node.js - 修改html文件时Nodemon不会重新启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37731012/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com