首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >盖茨比生成错误95313 -不构建项目

盖茨比生成错误95313 -不构建项目
EN

Stack Overflow用户
提问于 2021-07-22 15:16:44
回答 1查看 1.2K关注 0票数 0

盖茨比错误#95313中的生成错误

为path“/components/设置/”构建静态HTML失败

生成时出现错误的组件是

代码语言:javascript
复制
export const sc = () => {
  if (typeof window == "undefined") return {}
  else
    return {
      lgScr: window.innerHeight >= 901,
      smScr: window.innerHeight >= 635 && window.innerHeight < 900,
      mobile: window.innerWidth < 600,
    }
}

错误日志

错误

代码语言:javascript
复制
Page data from page-data.json for the failed page "/components/settings/": {
  "componentChunkName": "component---src-pages-components-settings-js",
  "path": "/components/settings/",
  "result": {
    "pageContext": {}
  },
  "staticQueryHashes": []
}

为页面构建静态HTML失败-0.592 s

错误#95313

为path“/components/设置/”构建静态HTML失败

有关此错误的更多信息,请参见文档页:https://gatsby.dev/debug-html

WebpackError:小型化反应错误#130;访问https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=object&args[]=获取完整消息,或使用非小型化开发环境nt获取全部错误和其他有用的警告。

  • static-entry.js:286 webpack:/gatsby-starter-hello-world/.cache/static-entry.js:286:22

gatsby-starter-hello-world/@gatsbyjs/reach-router/es/lib/utils.js:22:1

  • utils.js:22 utils.js:22
EN

回答 1

Stack Overflow用户

发布于 2021-07-22 16:23:57

如果它是一个应该大写的组件(Sc),那么如果它是一个独立的函数,它可以被称为sc。此外,尝试恢复条件。您只希望在定义了window数据(与undefined不同,else条件不同)时才使用它:

代码语言:javascript
复制
export const Sc = () => {
  if (typeof window !== "undefined") {
  return {
      lgScr: window.innerHeight >= 901,
      smScr: window.innerHeight >= 635 && window.innerHeight < 900,
      mobile: window.innerWidth < 600,
    } 
  }
  else return {}
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68487398

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档