简体   繁体   中英

Gatsby build error 95313 - Project not building

Building error in Gatsby ERROR #95313

Building static HTML failed for path "/components/settings/"

The component that's giving error while building is

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,
    }
}

Error Log

ERROR

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": []
}

failed Building static HTML for pages - 0.592s

ERROR #95313

Building static HTML failed for path "/components/settings/"

See our docs page for more info on this error: https://gatsby.dev/debug-html

WebpackError: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=object&args[]= for the full message or use the non-minified dev environme nt for full errors and additional helpful warnings.

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

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

If it's a component should be capitalized ( Sc ), if it's a standalone function it can be called sc . In addition, try to revert the condition. You only want to return the window data when it's defined (not the same than different than undefined , your else condition):

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 {}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM