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

TypeError: Cannot set properties of undefined (setting 'ko') #159

Open
crystalfp opened this issue Nov 18, 2021 · 1 comment
Open

TypeError: Cannot set properties of undefined (setting 'ko') #159

crystalfp opened this issue Nov 18, 2021 · 1 comment

Comments

@crystalfp
Copy link

Still struggling to load tko in an ES module.

I have installed @tko/build.reference.
Then in my module I import it this way:

import * as ko from "./node_modules/@tko/build.reference/dist/build.reference.js";

But Chrome on Windows answers with:

Uncaught TypeError: Cannot set properties of undefined (setting 'ko')
    at build.reference.js:10
    at build.reference.js:11

The same happens if I load build.reference.es6.js

Anyway, if you edit the file (build.reference*.js) and at line 10 change global into globalThis the error disappears.

Done this dirty fix, and overcoming some Typescript peculiarity, seems TKO works.

Thanks for continued support to this wonderful library!
mario

@crystalfp
Copy link
Author

The real problem is that both typeof exports and typeof module are undefined, so I cannot import the library this way as expected: import tko from "..../build.reference.es6.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

1 participant