Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_styledComponents.ServerStyleSheet is not a constructor error #3209

Closed
jaanhio opened this issue Dec 14, 2017 · 6 comments
Closed

_styledComponents.ServerStyleSheet is not a constructor error #3209

jaanhio opened this issue Dec 14, 2017 · 6 comments

Comments

@jaanhio
Copy link

jaanhio commented Dec 14, 2017

Description

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.

@jaanhio
Copy link
Author

jaanhio commented Dec 14, 2017

Issue can be closed. Realized its because i did not install the peer dependency for styled-components.

@jaanhio jaanhio closed this as completed Dec 14, 2017
@harmeetv
Copy link

@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)

@Boogieman66
Copy link

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
Copy link

sanjsanj commented 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
Copy link

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

@soroosh123rf
Copy link

I had the same problem and changed the import like this: import { ServerStyleSheets } from '@material-ui/styles' and now it's working fine again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants