TYPO3 – Add a JavaScript file and rendering the JS-file to a HTML file

I use TYPO3 ver. 10.4.21 and extensions sitepackage builder.

I added a JavaScript file in sitepackage, but my JavaScript codes don’t be read. Strictly speaking, javascript is read, but my JS codes don’t work on my page (HTML).

Maybe, my JS file doesn’t render my html file? I don’t know…..

In setup.typoscript:

includeJS {
        slider1_script = EXT:mein_projektarbeit/Resources/Public/JavaScript/Dist/slider1.js
        slider1_script.type = text/javascript
}
includeJSFooter {
        slider1_script = EXT:mein_projektarbeit/Resources/Public/JavaScript/Dist/slider1.js
        slider1_script.type = text/javascript
}

And in my html file (Slider1.html):

<html data-namespace-typo3-fluid="true" xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
    <f:comment>
        <link href="css/slider1.css" rel="stylesheet">
        <f:layout name="ContentElements/slider1" />
        <script src="{f:uri.resource(path: 'Public/JavaScript/Dist/slider1.js')}"></script>
    </f:comment>
    <f:section name="Main">
    <div class="menu-btn"></div>
       <div class="navigation">
           <div class="navigation-items">
              <a href="#">Home</a>
              <a href="#">About</a>
    .....

in my JS file (Slider1.js):

const menuBtn = document.querySelector(".menu-btn");
const navigation = document.querySelector(".navigation");

menuBtn.addEventListener("click", () => {
    menuBtn.classList.toggle("active");
    navigation.classList.toggle("active");
});

If I run this codes, then an error comes up:
enter image description here

I think the JS file doesN#t render into my html file, that’s why the error comes up.

Did I have to write more codes in html or setup.typoscript?

If I write my JS codes in html and I run them, the Javascript works well. But I want to separate the JS file and HTML file, because I want to use Fluid in my HTML file…
(JavaScript didn’t work, if I used fluid e.g. <data.variable> in my HTML file!)

I hope someone can help me with this problem.

Thank you.