#Internal server error: No hoisted script at index 0

5 messages · Page 1 of 1 (latest)

oak rover
#

I'm new to Astro and was just following along the tutorial and somewhere in this step something wired started happing(https://docs.astro.build/en/tutorial/3-components/4/).
Everytime I substitute the main page with the BaseLayout (as shown in the tutorial), I get "[ERROR] [vite] Internal server error: No hoisted script at index 0" this error. When I have the page the way it was before it doesn't happen. To make it even wireder it only happens with the index.astro file all the others (blog.astro and about.astro) work just fine.

index.astro (substituted):

---
import BaseLayout from '../layouts/BaseLayout.astro';
const pageTitle = "Home Page";
---
<BaseLayout>
  <h2>My awesome blog subtitle</h2>
</BaseLayout>

index.astro (original):

---
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import '../styles/global.css';
const { pageTitle } = Astro.props;
---

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
        <meta name="viewport" content="width=device-width" />
        <meta name="generator" content={Astro.generator} />
        <title>{pageTitle}</title>
    </head>
    <body>
        <Header />
        <h1>{pageTitle}</h1>
        <h2>My awesome blog subtitle</h2>
        <Footer />

        <script>
            import "../scripts/menu.js";
        </script>
    </body>
</html>

Does anyone know how to fix this? Thanks in advance. If you need more info to help me, just hit me up.

#

BaseLayout.astro:

---
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import '../styles/global.css';
const { pageTitle } = Astro.props;
---

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
        <meta name="viewport" content="width=device-width" />
        <meta name="generator" content={Astro.generator} />
        <title>{pageTitle}</title>
    </head>
    <body>
        <Header />
        <h1>{pageTitle}</h1>
        <slot />
        <Footer />

        <script>
            import "../scripts/menu.js";
        </script>
    </body>
</html>

This didn't fit into the other message

#

21:47:33 [ERROR] [vite] Internal server error: No hoisted script at index 0
at Context.load (file:///C:/Users/Main/WebstormProjects/astrotest/node_modules/astro/dist/vite-plugin-astro/index.js:85:19)
at Object.load (file:///C:/Users/Main/WebstormProjects/astrotest/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:50809:64)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async loadAndTransform (file:///C:/Users/Main/WebstormProjects/astrotest/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:53535:24)
at async viteTransformMiddleware (file:///C:/Users/Main/WebstormProjects/astrotest/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:63409:32)

And this is the full error.

winged robin
#

Hey! This is probably a bug knowing that some files in the stacktrace were edited recently. Feel free to open an issue!

open patioBOT
#

We love to keep the web weird, but... not that weird.

Please open an issue on the withastro/astro repo.