Recently, I encountered the “Parse failure: Unterminated string constant” error while working with a student who was using Astro on Windows. It’s worth noting that I couldn’t replicate this issue on macOS. The error occurred immediately after running the command npm run dev.

After thorough investigation and contemplation, we discovered that the problem was caused by a peculiar character within the parent folder’s name, possibly a non-ASCII character. Luckily, the solution was as simple as renaming the parent folder. We chose to rename it to a folder name consisting solely of ASCII characters, such as “test”.

If you ever encounter the “Parse failure: Unterminated string constant” error, I recommend trying the following troubleshooting step: Rename the folder you are currently working in (or even a parent folder within the path) using only ASCII text characters.

Tags: Astro, error fix, Parse failure, non-ASCII character