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

node-entry.js:6 Uncaught TypeError: Cannot assign to read only property 'document' of object '#<Window>' #297

Closed
pjkarlik opened this issue Dec 13, 2017 · 5 comments

Comments

@pjkarlik
Copy link

pjkarlik commented Dec 13, 2017

using webpack and three.js I get this when adding as import into my js page..

node-entry.js:6 Uncaught TypeError: Cannot assign to read only property 'document' of object '#'

unsure if I'm importing or using it right in the context of webpack builds...

@jsantell
Copy link
Contributor

This is for node-like environments where the globals do not exist, but something in that webpack configuration must be triggering this by providing a global object. Either way, we should check before overwriting these values. I'll have a PR shortly.

@jsantell
Copy link
Contributor

Can you confirm if changing src/node-entry to this works for you?

if (typeof global !== 'undefined' && global.window) {
  if (!global.document) {
    global.document = global.window.document;
  }
  if (!global.navigator) {
    global.navigator = global.window.navigator;
  }
}

require('./main');

jsantell added a commit that referenced this issue Dec 13, 2017
…ee.js source code, fix #297 with global.document clobbering, and fix typo in webvr-polyfill.js
@pjkarlik
Copy link
Author

I no longer get that issue - that fixed the import issue using webpack!! YAY!!

@jsantell
Copy link
Contributor

I just recreated this issue myself, thanks for reporting! I'll have a fix shortly

@jsantell
Copy link
Contributor

Fixed via 878873d

jsantell added a commit that referenced this issue Dec 14, 2017
…ee.js source code, fix #297 with global.document clobbering, and fix typo in webvr-polyfill.js
jsantell added a commit that referenced this issue Dec 14, 2017
…ee.js source code, fix #297 with global.document clobbering, and fix typo in webvr-polyfill.js
jsantell added a commit that referenced this issue Dec 14, 2017
…ee.js source code, fix #297 with global.document clobbering, and fix typo in webvr-polyfill.js
jsantell added a commit that referenced this issue Dec 18, 2017
…ee.js source code, fix #297 with global.document clobbering, and fix typo in webvr-polyfill.js
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

2 participants