我正在尝试将我现有的ReactJS应用程序与WordPress后端迁移到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
是否仍然有效。但卸载和重新安装软件包仍然没有解决我的问题。任何帮助或提示将不胜感激。
2条答案
按热度按时间6tdlim6h1#
我也有同样的问题。我已经通过清理浏览器缓存修复了它。我在清理Chrome的缓存之前做了
gatsby clean
,但我认为这无关紧要。k0pti3hp2#
我有这个问题与
gatsby-plugin-offline
插件,清理该高速缓存没有帮助,所以我禁用了插件的development
(本地)环境,它工作良好的生产