javascript - Gatsby:在页面节点上调用“touchNode”会引发“TypeError:locationAndPageResources.pageResources is undefined”
问题描述
当您转到希望缓存的页面时,在页面上调用 touchNode(来自源插件)会导致以下错误:
类型错误:locationAndPageResources.pageResources 未定义
// Code here checks if the page node in Gatsby cache is the same version
// as backend version. If so 'touch it' and don't recreate.
await Promise.all(result.data.pages.map(async page => {
const pageCacheKey = `cache-${page.url}`
const cacheResult = await pageRecords.getKey(pageCacheKey)
if (cacheResult) {
const node = pageNodes.find(node => {
if (!node.context)
return
return node.context.url == page.url
})
if (node) {
if (node.context.lastPublishedAt == page.lastPublishedAt) {
pageRecords.setKey(pageCacheKey, localPublishedAt)
return touchNode({
nodeId: node.id
})
}
}
}
}))
预期结果
页面节点应该持续存在而无需重新创建它(并且不需要后端)。
实际结果
解决方案
删除我的 index.js 文件后,我遇到了同样的错误。
我跑了gatsby clean
,然后gatsby develop
。这解决了问题。
推荐阅读
- c - C:使用 scanf 将“字符串”放入 char 数组时,char 数组中的附加字符,
- reactjs - 使用 useCallback 重构 useEffect 钩子 - React
- javascript - Three.js OrbitControls 围绕环旋转
- reactjs - React:上下文挂钩,将对象推入数组
- keras - 为什么 CuDNNLSTM 在 keras 中比 LSTM 有更多的参数?
- regex - 0 到 299 之间的字符串的正则表达式,后跟 x 和 y 的某种组合
- python - 如何模拟请求中的按钮单击?
- android - 如何获取具有这种格式的 URI content://xx.xxx.xxx.file_provider/file%253A%2...等
- python - ElementNotInteractableException:将文本发送到电子邮件字段的元素不可交互错误
- jquery - jQuery Ajax GET 请求在某些情况下返回 500 错误