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

React-Hot-Loader is not supported in this environment. #1188

Closed
wulucxy opened this issue Feb 22, 2019 · 5 comments
Closed

React-Hot-Loader is not supported in this environment. #1188

wulucxy opened this issue Feb 22, 2019 · 5 comments

Comments

@wulucxy
Copy link

wulucxy commented Feb 22, 2019

If you are reporting a bug or having an issue setting up React Hot Loader, please fill in below. For feature requests, feel free to remove this template entirely.

Description

when run npm start,cli will console out:

React-Hot-Loader is not supported in this environment.

Expected behavior

when run npm script,why did this happen?

Actual behavior

not waring msg

Environment

React Hot Loader version: 4.7.1

Run these commands in the project folder and fill in their results:

  1. node -v: 8.10.0
  2. npm -v: 5.6.0
@borisding
Copy link

Hi!

I'm having same message after applying https://github.com/gaearon/react-hot-loader#webpack-plugin for my SSR project.

@theKashey
Copy link
Collaborator

  var evalAllowed = false;
  try {
    eval('evalAllowed = true');
  } catch (e) {
    // eval not allowed due to CSP
  }

  // RHL needs setPrototypeOf to operate Component inheritance, and eval to patch methods
  var jsFeaturesPresent = typeof window !== 'undefined' && !!Object.setPrototypeOf;

  if (!jsFeaturesPresent || !evalAllowed) {
    // we are not in prod mode, but RHL could not be activated
    console.warn('React-Hot-Loader is not supported in this environment.');
    ....
  }

So, which variable - jsFeaturesPresent or evalAllowed is falsy?

@borisding
Copy link

  var evalAllowed = false;
  try {
    eval('evalAllowed = true');
  } catch (e) {
    // eval not allowed due to CSP
  }

  // RHL needs setPrototypeOf to operate Component inheritance, and eval to patch methods
  var jsFeaturesPresent = typeof window !== 'undefined' && !!Object.setPrototypeOf;

  if (!jsFeaturesPresent || !evalAllowed) {
    // we are not in prod mode, but RHL could not be activated
    console.warn('React-Hot-Loader is not supported in this environment.');
    ....
  }

So, which variable - jsFeaturesPresent or evalAllowed is falsy?

It's showing

jsFeaturesPresent: false
evalAllowed: true

@taikn
Copy link

taikn commented Mar 2, 2019

Same here jsFeaturesPresent: false, typeof window is undefined

@theKashey
Copy link
Collaborator

@borisding - so there is no window in SSR, and there is no RHL on SSR side - it relies on module update API, which does not exist on the server side.

I would say - the right way to mitigate the problem - suppress this message on SSR.

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

4 participants