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

Error 'ReferenceError: "window" is not defined' in browserless environment #500

Closed
wants to merge 1 commit into from

Conversation

teur
Copy link

@teur teur commented Aug 26, 2016

An issue occurs when polyfills.js is being used in a browserless environment, such as being run directly using Node or Nashorn.

@ghost
Copy link

ghost commented Aug 26, 2016

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@ghost ghost added the CLA Signed label Aug 26, 2016
@gaearon
Copy link
Contributor

gaearon commented Aug 26, 2016

What is your use case for running CRA code in a server environment?

@teur
Copy link
Author

teur commented Aug 26, 2016

I want to build an isomorphic application using ReactDomServer.renderToString.

@gaearon
Copy link
Contributor

gaearon commented Aug 26, 2016

Create React App doesn’t currently support server rendering, sorry. See #91.
Some of the alternatives might support it.

@gaearon gaearon closed this Aug 26, 2016
@teur
Copy link
Author

teur commented Aug 26, 2016

Everything else SSR works fine, just one "window" problem is in polyfills.js for me.
But anyway thanks for your answer.

@gaearon
Copy link
Contributor

gaearon commented Aug 26, 2016

How do you configure Babel on the server? We don’t expose Babel configs so I’m not sure how that works for you.

@teur
Copy link
Author

teur commented Aug 26, 2016

I don't use babel on server, I need only a compiled main.*.js result file. I am using java/nashorn js implementation like in https://github.com/pugnascotia/spring-react-boilerplate.

@gaearon
Copy link
Contributor

gaearon commented Aug 26, 2016

How do you switch between server and client implementation? Do you just check if window is available?

@teur
Copy link
Author

teur commented Aug 26, 2016

Yes, you are right. I am checking it.

@gaearon
Copy link
Contributor

gaearon commented Aug 26, 2016

How do you find the build output? Do you just take the first .js file in the build folder?

@teur
Copy link
Author

teur commented Aug 26, 2016

After executing "react-scripts build" I have only one js file like main.*.js in build/static/js folder, so I take it.

@gaearon
Copy link
Contributor

gaearon commented Aug 26, 2016

I see. This might become harder in the future if we start splitting it up into additional bundles. I’d say we don’t officially support that, so your best bet is to eject and then do anything you would like.

@teur
Copy link
Author

teur commented Aug 26, 2016

ok, thanks a lot.

@gaearon
Copy link
Contributor

gaearon commented Aug 26, 2016

Yea, sorry if it’s frustrating. Can’t solve all problems in one tool 😄 .

@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants