Uncaught ReferenceError: module is not defined when importing polyfill script
See original GitHub issueCurrent behavior
Hi, I’m using sweet alert 2 in my project I use plain javascript I imported the library like this
<script src="sweetalert2.all.min.js"></script>
It just works fine in my browser. But I realized, that sweet alert 2 is a promise based library so I had to polyfil it. So I imported the polyfill script just like in the documentation
<script src="sweetalert2.all.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill"></script>
But I got this error in my console
index.js:274 Uncaught ReferenceError: module is not defined
at index.js:274
The library works fine, but I’m just wondering if this error cause the polyfill script doesn’t work so the older browser can’t use the Promise feature that this library use
Expected behavior
No errors, works fine for older browsers
Live demo
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
I cannot fix this error: Uncaught ReferenceError: module is not ...
I am exporting my js file, so I can use import into my unit test file. Here is my js ...
Read more >Module Methods - webpack
This section covers all methods available in code compiled with webpack. When using webpack to bundle your application, you can pick from a...
Read more >ReferenceError: exports is not defined in ES module scope
Node version: 18. I'm trying to run my project with: node dist/index.js. My tsconfig.json "lib": ["ES5"]. "module": "CommonJS".
Read more >systemjs/systemjs - Gitter
Hi Guys, I am getting the following error: "Uncaught (in promise): TypeError: System.import is not a function" when I am lazy loading a...
Read more >How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
However, tree-shaking is not the only speed/performance benefit of Rollup. ... For example, in src/scripts/modules/mod1.js , there's a function called ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@dytra you are importing the wrong file from the
promise-polyfill
. As per the README, you need to use:This still happening