Common Errors: Parse failure: Unterminated string constant

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


This error can appear when running build tools like Astro, Webpack, or other bundlers:

Parse failure: Unterminated string constant

The cause

This error is often caused by special characters in your file path or folder names, particularly non-ASCII characters.

This issue has been observed primarily on Windows systems.

The fix

Rename the folder you’re running the project in (or a parent folder in the path) to use only ASCII characters.

For example, change:

  • Mon ProjetMonProjet or my-project
  • CódigoCodigo or code
  • DéveloppementDevelopment or dev

Other potential causes

If renaming doesn’t help, the error might also be caused by:

  1. Actual unterminated strings in your code: Check for missing closing quotes

    // Bad
    const str = "Hello world
    
    // Good
    const str = "Hello world"
  2. Multi-line strings without proper syntax:

    // Bad
    const str = "Line 1
    Line 2"
    
    // Good - use template literals
    const str = `Line 1
    Line 2`
  3. Encoding issues: Make sure your files are saved with UTF-8 encoding

  4. Copy-pasted “smart quotes”: Word processors sometimes convert straight quotes to curly quotes

    // Bad (smart quotes)
    const str = "Hello"
    
    // Good (straight quotes)
    const str = "Hello"

Lessons in this unit:

0: Introduction
1: "X is not a function" errors
2: "document is not defined" error
3: Cannot assign to read only property
4: ▶︎ Parse failure: Unterminated string constant
5: FormData multipart fetch issues
6: regeneratorRuntime is not defined
7: Unexpected identifier in modules
8: Unterminated string literal