Astro - TypeError: Cannot read properties of undefined (reading 'document')

Viewed 71

I am moving my blog to Astro and wanted to import some javascript using jquery.

In the Layout file I first import the jquery file (3.6.1) and then import my javascript file.

---
import "../scripts/jquery.js";
import "../scripts/main.js";
---

<!DOCTYPE html>
...

However I get the error (regarding the jquery file):

TypeError: Cannot read properties of undefined (reading 'document')
1 Answers

Try importing your files with script tag :

<script src="../scripts/jquery.js"></script>
Related