Skip to content

🐛 BUG: Critical Compiler Panic on Windows: bad parser state & cannot read 'exports' #1094

@erfaja

Description

@erfaja

What version of @astrojs/compiler are you using?

2.12.2

What package manager are you using?

npm

What operating system are you using?

windows

Describe the Bug

What is the bug?

I am experiencing a persistent, critical compiler bug on my Windows 11 machine that makes Astro completely unusable for my project. The development server will not start and consistently throws a low-level panic error.

The Error Messages

The primary crash is a Go panic: panic: html: bad parser state: originalIM was set twice

This results in the user-facing error: UnknownCompilerError: Cannot read properties of undefined (reading 'exports').

The error always points to my src/layouts/Layout.astro file, but the trigger seems to be the CSS import.

What I Have Tried (Everything)

I have worked extensively with an AI assistant to solve this, and we have tried every possible solution. The bug still remains. We have tried:

  1. Creating a brand new, empty Astro project. The error still happens as soon as I try to build my layout.
  2. Completely uninstalling Node.js, manually deleting all npm and npm-cache folders from %appdata%, and reinstalling the latest Node.js LTS version. The bug remains.
  3. Cleaning the npm cache with npm cache clean --force.
  4. Moving the project to a path with no spaces (e.g., C:/dev/project).
  5. Recreating the Layout.astro file from scratch with minimal code.
  6. Isolating the trigger:
    • A bare-bones Layout.astro file without any imports works.
    • The server crashes as soon as I add the line import "../styles/global.css"; to the layout.
    • We found and fixed a syntax error in the global.css file, but the panic still occurs when importing the corrected CSS file.

Conclusion

There is a fundamental incompatibility between the Astro WASM compiler and something within my project's CSS file or dependency graph that is causing a non-recoverable crash. The tool is failing at a level that is impossible for me to debug further. My project is currently completely blocked. Please help.

Link to Minimal Reproducible Example

Cannot reproduce online. Bug is local to my Windows machine. See steps in description.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions