Error in the console log: "Uncaught ReferenceError: module is not defined"
This is what is causing the error:
<script src="https://cdn.jsdelivr.net/npm/js-cookie@rc/dist/js.cookie.min.js"></script>
Does this happen to anyone else on Chrome and firefox? Does anyone have a solution?
This wasn't happening before, but started today.
Answer: Execute Code after jQuery Library has Loaded The most common reason behind the error "Uncaught ReferenceError: $ is not defined" is executing the jQuery code before the jQuery library file has loaded. Therefore make sure that you're executing the jQuery code only after jQuery library file has finished loading.
The ReferenceError object represents an error when a variable that doesn't exist (or hasn't yet been initialized) in the current scope is referenced. ReferenceError is a serializable object, so it can be cloned with structuredClone() or copied between Workers using postMessage() .
A not defined error is when we did not declare the variable and tried to call that variable. In JavaScript, we can declare variables without adding const , let , or var , and we won't get an error of undefined or not defined . This can be seen in the code below.
To solve the"ReferenceError: document is not defined" error, make sure to only use the document global variable on the browser. The variable relates to the Document Object Model, which represents a web page that is loaded in the browser and can't be used on the server side (e.g. in Node. js).
So it turns out it's the js-cookie's most recent release that broke things.
I posted the issue on their github repo and got a work around, until they solve this issue in their latest release:
https://github.com/js-cookie/js-cookie/issues/698
Elte156 said that to use this earlier version for now, until the breaking change resolves:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js.cookie.min.js"></script>
I can confirm that this work around works for me.
Major releases of packages can shift around files. In this case the referenced file became a CommonJS module, which doesn't run directly in the browser. The good news is that many packages, including the new version of js-cookie, tell jsdelivr which file to use by default.
If you use this url, everything should keep working: https://cdn.jsdelivr.net/npm/js-cookie@rc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With