question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught ReferenceError: module is not defined when importing polyfill script

See original GitHub issue

Current 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

https://jsfiddle.net/dytra/Lep7rdfw/2/#save

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
gvernicommented, Jul 18, 2019

@dytra you are importing the wrong file from the promise-polyfill. As per the README, you need to use:

<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.js"></script>
0reactions
Abel7xcommented, May 18, 2020

This still happening

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found