简体   繁体   English

是什么导致npm live-server停止检测文件更改?

[英]What would cause npm live-server to stop detecting file changes?

This was working on my system and now is not. 这在我的系统上正在运行,但现在没有。 I have live-server version 0.8.1 installed globally. 我已经在全球范围内安装了实时服务器版本0.8.1。

npm install live-server -g

But when I start it I don't get the "Live reload enabled." 但是,当我启动它时,并没有启用“实时重新加载”。 message in the browser console. 浏览器控制台中的消息。

I've uninstalled it completely and re-installed it to no avail. 我已经完全卸载了它,但是重新安装却无济于事。

The http server is working. http服务器正在运行。 It will serve up my index.html and all related content. 它将提供我的index.html和所有相关内容。 It just won't detect file changes. 它只是不会检测文件更改。

Starting live-server: 启动实时服务器:

live-server --open=src

I'm using typescript outputting js to src/dist/... I've verified that the file is changing. 我正在使用将js输出到src / dist /的Typescript ......我已验证文件正在更改。 I can modify the js directly as well. 我也可以直接修改js。 In no case does live-server detect any changes. 实时服务器决不会检测到任何更改。

File system permissions? 文件系统权限? Cached configuration? 缓存配置?

What's causing this? 是什么原因造成的?

I had been having this issue as well, and stumbled across one exchange between Ritwick Dey (author of live-server), and a dev having the same issues. 我也一直遇到这个问题,偶然发现Ritwick Dey(实时服务器的作者)和一个有相同问题的开发人员之间发生了一次交流。

As it turns out, it's as simple as not using a self-closing tag. 事实证明,这就像不使用自闭标签一样简单。

In my case, I was using React, and the line in question (in my HTML file) was 就我而言,我使用的是React,相关的行(在我的HTML文件中)是

<script src="/scripts/app.js" />

Changing it to the following immediately fixed my issue, and got the "Live reload enabled" message in my Console, and hot reloading to work again. 将其更改为以下内容可立即解决我的问题,并在控制台中显示“启用实时重新加载”消息,然后重新进行热加载即可正常工作。

<script src="/scripts/app.js"></script>

Hope this helps. 希望这可以帮助。

(here's a link to the conversation: https://github.com/ritwickdey/vscode-live-server/issues/82 ) (这是对话的链接: https : //github.com/ritwickdey/vscode-live-server/issues/82

This may have been a Chrome caching issue. 这可能是Chrome缓存问题。 I opened Safari and voila, everything started working. 我打开Safari和voila,一切都开始工作了。 Closed Safari and now Chrome is working again. 关闭Safari,现在Chrome可以再次使用了。

I'm going to call this a bizarre environmental fluke. 我将这称为奇怪的环境environmental幸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用npm live-server时是否清除localStorage? - Does the localStorage get cleared when working with npm live-server? 如何在 VSCode chrome live-server 中运行 npm 模块(puppeteer)? - How to run npm module (puppeteer) in a VSCode chrome live-server? 使用 npm 安装 live-server 包时出错。 `npm audit` 无助于解决问题 - Getting error while installing live-server package using npm. `npm audit` is not helping to fix the problem npm live-server安装:symlink错误(即使以root / admin身份运行) - npm live-server install: symlink error (even when running as root/admin) 在 Visual Studio Code 中编码时如何阻止实时服务器自动打开浏览器? - How to stop live-server opening the browser automatically while coding in Visual Studio Code? 为什么实时服务器会注入这些 javascript 代码 - why is live-server injecting these javascript codes 当我启动 live-server 时,TailwindCss 类没有反映出来 - TailwindCss classes are not reflected when i start live-server yarn eg:&#39;live-server&#39; 不被识别为内部或外部命令 - yarn eg:'live-server' is not recognized as an internal or external command 如何在运行实时服务器的情况下在 Visual Studio Code 中调试 JavaScript - How to Debug JavaScript in Visual Studio Code with live-server Running 关闭和打开应用程序的实时服务器会删除我的本地存储 - closing and opening live-server for an app deletes my local storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM