javascript - Gatsby - 无法读取未定义的属性“组件---src-pages-index-jsx”
问题描述
我正在尝试将带有 WordPress 后端的现有 ReactJS 应用程序迁移到 GatsbyJS。我是 GatsbyJS 的新手,并按照他们页面上的说明在 Windows 10 机器上进行设置。设置运行得很好,我可以开始我的迁移过程,但一段时间后,我在尝试加载页面时只收到以下错误:
TypeError: Cannot read property 'component---src-pages-index-jsx' of undefined
fetchResource
D:/GitHub/gatsby-starter-wordpress/.cache/loader.js:77
74 | // Find resource
75 | let resourceFunction
76 | if (resourceName.slice(0, 12) === `component---`) {
> 77 | resourceFunction = asyncRequires.components[resourceName]
78 | } else if (resourceName.slice(0, 9) === `layout---`) {
79 | resourceFunction = asyncRequires.layouts[resourceName]
80 | } else {
View compiled
getResourceModule
D:/GitHub/gatsby-starter-wordpress/.cache/loader.js:112
109 | cb(failedResources[resourceName])
110 | })
111 | } else {
> 112 | fetchResource(resourceName, (err, executeChunk) => {
113 | if (err) {
114 | cb(err)
115 | } else {
View compiled
getResourcesForPathname
D:/GitHub/gatsby-starter-wordpress/.cache/loader.js:358
355 | })
356 | }
357 | }
> 358 | getResourceModule(page.componentChunkName, (err, c) => {
359 | if (err) {
360 | handleResourceLoadError(
361 | page.path,
View compiled
new ComponentRenderer
D:/GitHub/gatsby-starter-wordpress/.cache/component-renderer.js:26
23 |
24 | this.state = {
25 | location,
> 26 | pageResources: loader.getResourcesForPathname(location.pathname),
27 | }
28 | }
29 |
View compiled
▶ 43 stack frames were collapsed.
(anonymous function)
D:/GitHub/gatsby-starter-wordpress/.cache/app.js:42
39 | Root = Root.default
40 | }
41 |
> 42 | domReady(() =>
43 | ReactDOM.render(
44 | <HotContainer>
45 | <Root />
View compiled
HTMLDocument.listener
D:/GitHub/gatsby-starter-wordpress/node_modules/domready/ready.js:23
我尝试删除任何自定义编写的组件,直到我最终得到正常的起始样板。但它仍然行不通。所以我继续,甚至创建了一个新项目来测试是否gatsby-cli
仍然有效。但是卸载并重新安装软件包仍然没有解决我的问题。任何帮助或提示将不胜感激。
解决方案
我有同样的问题。我已经通过清理浏览器缓存来修复它。我gatsby clean
在清理 chrome 的缓存之前已经完成了,但我认为这不相关。
推荐阅读
- angular - 量角器 - 如何从多选下拉列表中选择元素
- vb.net - LINQ、加入、GroupBy 和计数
- node.js - 无法在 MongoDB 中多次保存相同的条目
- react-native - “您无权访问”错误我该怎么办?
- python - Python - 创建了一个 .exe,但结果未显示
- c# - 如何将对象类型更改为其实际类型?
- c# - 使用 C# 从文件中解析 JSON 数据
- google-kubernetes-engine - 在 GKE 上禁用自动集群修复
- c++ - 基于文本的不同距离计算或指纹算法
- r - RNA-seq 数据分析中的报告工具:使用 GOstats 进行 GO 分析会出错