You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
_styledComponents.ServerStyleSheet is not a constructor error #3209
error Building static HTML for pages failed`
`See our docs page on debugging HTML builds for help https://goo.gl/yL9lND`
`16 | setHeadComponents = _ref.setHeadComponents;
17 |
> 18 | var sheet = new _styledComponents.ServerStyleSheet();
| ^
19 |
20 | var app = _react2.default.createElement(
21 | _styledComponents.StyleSheetManager,`
`WebpackError: _styledComponents.ServerStyleSheet is not a constructor`
- gatsby-ssr.js:18 Object.exports.replaceRenderer
~/gatsby-plugin-styled-components/gatsby-ssr.js:18:1
- api-runner-ssr.js:23
.cache/api-runner-ssr.js:23:41
- api-runner-ssr.js:21 module.exports
.cache/api-runner-ssr.js:21:25
- static-entry.js:113 module.exports
.cache/static-entry.js:113:3
- static-entry.js:99 Function.Promise.fromNode.Promise.fromCallback
.cache/static-entry.js:99:20
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I am using gatsby-plugin-styled-components: "2.0.2"and styled-components: "2.2.4".
gatsby-pluging-styled-components should have handled the SSR right? or do i still have to configure it manually? it worked fine a few months ago when i deployed the first version of my github page.
@jaanhio Can you explain how did you solved this? I am also getting same kind of error.
TypeError: _material_ui_core_styles__WEBPACK_IMPORTED_MODULE_10__.ServerStyleSheets is not a constructor
at eval (webpack:///./server/helpers/renderer.js?:37:16)
at eval (webpack:///./server/index.js?:54:81)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Just had the same issue on my Next build, I ended up with the alpha release of "@material-ui/core": "^5.0.0-alpha.33" in my package.json, I swapped it over to the latest stable release "^4.11.4" and it works now.
Reacted by Caio Borghi, Tim Rots and Sanjay Purswani
Same thing here @sanjsanj. My next build command was working until this latest release of 5.0.0-alpha.33 but after the update it crashes.
Error message:
Error occurred prerendering page "/auth/login". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: material_ui_core_styles__WEBPACK_IMPORTED_MODULE_3_.ServerStyleSheets is not a constructor
at Function.exports.modules.1225.MyDocument.getInitialProps
Reacted by Herve Berard, Sanjay Purswani and Davis Jones
Activity
jaanhio commentedon Dec 14, 2017
Issue can be closed. Realized its because i did not install the peer dependency for styled-components.
harmeetv commentedon Nov 23, 2019
@jaanhio Can you explain how did you solved this? I am also getting same kind of error.
Boogieman66 commentedon Mar 11, 2020
For anyone coming here from google....
make sure @material-ui/core/styles actually exports ServerStyleSheets
this lead me to realize I'm running an older material-ui/core (3.9.x)
fixed by upgrading to 4.5.1
sanjsanj commentedon May 18, 2021
Just had the same issue on my Next build, I ended up with the alpha release of
"@material-ui/core": "^5.0.0-alpha.33"in my package.json, I swapped it over to the latest stable release"^4.11.4"and it works now.ocodista commentedon May 18, 2021
Same thing here @sanjsanj. My
next buildcommand was working until this latest release of 5.0.0-alpha.33 but after the update it crashes.Error message:
Error occurred prerendering page "/auth/login". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: material_ui_core_styles__WEBPACK_IMPORTED_MODULE_3_.ServerStyleSheets is not a constructor
at Function.exports.modules.1225.MyDocument.getInitialProps
soroosh123rf commentedon May 27, 2021
I had the same problem and changed the import like this:
import { ServerStyleSheets } from '@material-ui/styles'and now it's working fine again.