Gatsby 热重载不会在 Hello World 启动项目中重载
Gatsby hot reloading does not reload in the Hello World starter project
描述
我正在按照此处的说明进行操作:https://www.gatsbyjs.org/tutorial/part-one/
当我启动开发服务器并对 src/pages/index.js 进行更改时,它不会在我的浏览器中重新加载。
重现步骤
使用 gatsby-cli:
- gatsby new hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world
- cd 你好世界
- 盖茨比开发
- 更改 src/pages/index.js
中 div 内的文本
预期结果
页面将自动重新加载新文本。
实际结果
除非在浏览器中应用手动刷新,否则页面不会更改。
规格
OS:Ubuntu 18.04.3 LTS 运行 在 Windows 10 Pro
上的 WSL 中
节点: 12.12.0
NPM: 6.11.3
Gatsby CLI: 2.8.8
盖茨比: 2.17.6
浏览器:Chrome 77.0.3865.120,IE 11.1006.17134.0,Firefox 70.0
我尝试了多个浏览器,结果相同,所以我在 firefox 中 运行 devtools 并在我进行更改时检查了控制台输出,我看到了这个错误:
The connection to http://localhost:8000/__webpack_hmr was interrupted while the page was loading. client.js:88
[HMR] Update check failed: hotDownloadManifest/</request.onreadystatechange@http://localhost:8000/commons.js:42:16
process-update.js:147
Error: Manifest request to /d528b21bff3fd2caa92d.hot-update.json timed out. bootstrap:41
Firefox can’t establish a connection to the server at http://localhost:8000/__webpack_hmr. client.js:88
我也查看了 github 和此处,但没有找到解决我的问题的方法。任何关于变通方法、解决方案的想法或对为什么这对我不起作用的见解都将不胜感激!
我今天遇到了类似的情况。下面的步骤使它工作但是警告消息在控制台中持续存在。
- 删除 package.lock.json 和 node_modules 文件夹
- 删除 C:\Users\\AppData\Roaming\npm 和 npm-cache
中的内容
- 做一个
npm i
.
我遇到了同样的问题。每当我对文件进行更改时,Gatsby Develop 热重载都不起作用,此外,Gatsby Develop 编译代码和启动开发服务器以及 运行ning 的速度非常慢。我发现,如果我在 Linux 目录结构而不是 Windows 中创建我的 Gatsby 项目,一切都很好,而且速度非常快。所以我的解决方案如下。
在 WSL 的 /home/<your_username>
目录中创建您的项目。只需转到 /home/<your_username>
并在那里创建一个文件夹 mkdir
;转到该文件夹,然后在该文件夹中执行 运行 Gatsby create my_project
命令。
这样您的项目将驻留在 Linux 目录结构中,使一切 运行 顺利进行。
我在 windows 运行 gatsby develop
。在尝试了很多东西之后,包括 wsl、npm clenaup 等,我意识到我的杀毒软件 sophos 正在阻止 webpack 热重载套接字 __webpack_hmr
.
All I had to do is to disable the antivirus for a while. ( You are free to uninstall it or maybe change to another one ).
希望对你有用 ;)
描述
我正在按照此处的说明进行操作:https://www.gatsbyjs.org/tutorial/part-one/ 当我启动开发服务器并对 src/pages/index.js 进行更改时,它不会在我的浏览器中重新加载。
重现步骤
使用 gatsby-cli:
- gatsby new hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world
- cd 你好世界
- 盖茨比开发
- 更改 src/pages/index.js 中 div 内的文本
预期结果
页面将自动重新加载新文本。
实际结果
除非在浏览器中应用手动刷新,否则页面不会更改。
规格
OS:Ubuntu 18.04.3 LTS 运行 在 Windows 10 Pro
上的 WSL 中节点: 12.12.0
NPM: 6.11.3
Gatsby CLI: 2.8.8
盖茨比: 2.17.6
浏览器:Chrome 77.0.3865.120,IE 11.1006.17134.0,Firefox 70.0
我尝试了多个浏览器,结果相同,所以我在 firefox 中 运行 devtools 并在我进行更改时检查了控制台输出,我看到了这个错误:
The connection to http://localhost:8000/__webpack_hmr was interrupted while the page was loading. client.js:88
[HMR] Update check failed: hotDownloadManifest/</request.onreadystatechange@http://localhost:8000/commons.js:42:16
process-update.js:147
Error: Manifest request to /d528b21bff3fd2caa92d.hot-update.json timed out. bootstrap:41
Firefox can’t establish a connection to the server at http://localhost:8000/__webpack_hmr. client.js:88
我也查看了 github 和此处,但没有找到解决我的问题的方法。任何关于变通方法、解决方案的想法或对为什么这对我不起作用的见解都将不胜感激!
我今天遇到了类似的情况。下面的步骤使它工作但是警告消息在控制台中持续存在。
- 删除 package.lock.json 和 node_modules 文件夹
- 删除 C:\Users\\AppData\Roaming\npm 和 npm-cache 中的内容
- 做一个
npm i
.
我遇到了同样的问题。每当我对文件进行更改时,Gatsby Develop 热重载都不起作用,此外,Gatsby Develop 编译代码和启动开发服务器以及 运行ning 的速度非常慢。我发现,如果我在 Linux 目录结构而不是 Windows 中创建我的 Gatsby 项目,一切都很好,而且速度非常快。所以我的解决方案如下。
在 WSL 的 /home/<your_username>
目录中创建您的项目。只需转到 /home/<your_username>
并在那里创建一个文件夹 mkdir
;转到该文件夹,然后在该文件夹中执行 运行 Gatsby create my_project
命令。
这样您的项目将驻留在 Linux 目录结构中,使一切 运行 顺利进行。
我在 windows 运行 gatsby develop
。在尝试了很多东西之后,包括 wsl、npm clenaup 等,我意识到我的杀毒软件 sophos 正在阻止 webpack 热重载套接字 __webpack_hmr
.
All I had to do is to disable the antivirus for a while. ( You are free to uninstall it or maybe change to another one ).
希望对你有用 ;)