_styledComponents.ServerStyleSheet is not a constructor error
See original GitHub issueDescription
I am getting this webpack error when running yarn deploy for my github page.
"deploy": "gatsby build --prefix-paths && gh-pages -d public",
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.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
trying SSR but got "ServerStyleSheets is not a constructor"
I realized in my @material-ui/core it doens't install ThemeProvider & ServerStyleSheets. I installed @material-ui/styles then it worked. – Hang ...
Read more >API Reference - styled-components
Returns a StyledComponent that does not accept children. Place it at the top of your React tree and the global styles will be...
Read more >JavaScript-less Static SSR using Styled Components
I used React's ReactDOMServer.renderToStaticMarkup and Styled Components' ServerStyleSheet.collectStyles to render a completely static site with CSS and no JS.
Read more >styled-components | Yarn - Package Manager
Use the best bits of ES6 and CSS to style your apps without stress ... If a contribution does not have a mention...
Read more >styled-components - UNPKG
The CDN for styled-components. ... insertRule(rule, index);\n this.length++;\n return true;\n } catch (_error) {\n return false;\n }\n }\n\n ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same problem and changed the import like this:
import { ServerStyleSheets } from '@material-ui/styles'
and now it’s working fine again.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