-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Allow video.js to be run in node #3869
Comments
You should be able to Rather, use |
That's what we're requiring - but since everything is browserified/webpacked, the same code will run in node and in the browser for us. Why is document.createElement being called without checking for its existence first, even in the browser build? |
@ljharb @nicksorrentino Will #3889 address your issue? It allows |
@misteroneill thanks! close - i made some comments. It's totally fine for anything to throw in node as long as it's not upon require. |
Agreed 💯 thanks for bringing it to our attention! |
Introduce the Dom.isReal() function, which makes an educated assumption about the "realness" of the document object. Wrap code here and there with checks against Dom.isReal() as well as other defensive code. Fixes #3869.
This should be available as part of 5.15.1, in the |
Thanks! |
Thank you! |
Description
I am server rendering my frontend using node. We are unable to server render any modules that import video.js. Due to running
document.createElement
video.js/src/js/utils/browser.js
Line 74 in 881cfcb
Steps to reproduce
Explain in detail the exact steps necessary to reproduce the issue.
TypeError: _document2.default.createElement is not a function
Results
Expected
Video.js to not crash
Actual
It crashes running
document.createElement
Error output
TypeError: _document2.default.createElement is not a function
Additional Information
Please include any additional information necessary here. Including the following:
versions
videojs
what version of videojs does this occur with?
5.12.6
browsers
what browser are affected? None
OSes
what platforms (operating systems and devices) are affected? node any
cc @ljharb
The text was updated successfully, but these errors were encountered: