schedule/cjs/schedule.<env>.js thinks it is in the browser when run on the server
See original GitHub issueDo you want to request a feature or report a bug?
Bug
What is the current behavior?
Code meant to only run in the browser is running on the server. The error I’m seeing is:
UnhandledPromiseRejectionWarning: TypeError: window.addEventListener is not a function
at ./node_modules/react-dom/node_modules/schedule/cjs/schedule.development.js:366:10
at Object.<anonymous> (./node_modules/react-dom/node_modules/schedule/cjs/schedule.development.js:421:5)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (./node_modules/react-dom/node_modules/schedule/index.js:6:20)
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
We are using import { findDOMNode } from 'react-dom' in one of our components and the server render is broken due to this dependency/file being pulled in.
What is the expected behavior?
To not error, I guess. The root problem seems to be a faulty check of environment somewhere.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
This has been narrowed down to just 16.5.2 – doing nothing but downgrading to 16.5.1 using npm install --save react@16.5.1 react-dom@16.5.1 fixes the issue.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)

Top Related StackOverflow Question
Yeah, same issue. It means you define
windowon the server which ideally you shouldn’t be doing. But we adjusted the heuristic to also check forwindow.addEventListenerseparately in the next version.This seems related to this other issue: https://github.com/facebook/react/issues/13694 which looks like it is now fixed in master.