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

CDN script error: module not defined #134

Open
derek-ye opened this issue Feb 22, 2024 · 1 comment
Open

CDN script error: module not defined #134

derek-ye opened this issue Feb 22, 2024 · 1 comment

Comments

@derek-ye
Copy link

Description

I'm trying to embed the script in a static HTML file, but I'm running into the following error. I think it might be due to the script being a CommonJS module - any ideas on how I could fix this without converting the entire file to ESM?

index.js:3 Uncaught ReferenceError: module is not defined
    at index.js:3:1
(anonymous) @ index.js:3

HTML file:

<body>
    <script src="https://cdn.jsdelivr.net/npm/pixelmatch@5.3.0"></script>
    ...
@mourner
Copy link
Member

mourner commented Feb 23, 2024

Yeah, looks like we need to convert Pixelmatch to ESM to use it on the browser properly now. Meanwhile, as a workaround, maybe you could try using Skypack CDN which does CommonJS to ESM convertion automatically: https://cdn.skypack.dev/pixelmatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants