withastro/astro

Can't build astro if project path contains spaces on MacOS

Opened this issue · 7 comments

Astro Info

> astro info

Astro                    v5.0.0-beta.12
Node                     v18.20.4
System                   macOS (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

This might be an NPM or a Vite problem but I just started using Astro and it refuses to build if the project path contains a space on MacOS: for example, ".../new website" does not build, while ".../website" does.

The error is as follows:

astro vscode [ERROR] [vite] cannot find entry point module '.../Documents/new%20website/Site/node_modules/@astrojs/mdx/dist/server.js'.

It goes away if I change the path to the project to this: ".../Documents/Website/Site/node_modules/@astrojs/mdx/dist/server.js"

It was easy to fix for me, but I imagine if for example someone's username contains a space then they are in deep trouble.

What's the expected result?

Astro building my site.

Link to Minimal Reproducible Example

should be trivial to reproduce - in my case I just used the blog template and created a scratch project under a path with a space in the pathname.

Participation

  • I am willing to submit a pull request for this issue.

OK, I can reproduce this, and it's specifically an error in the MDX plugin. Thanks for the report!

Seems this was introduced in @astrojs/mdx@4.0.0-beta.4

Because of links etc, this can be reproduced in the Astro monorepo only if the monorepo itself has a space in the filename, or the package path.

Looks like this is a Vite bug: vitejs/vite#9917

Any workaround for this? Because it works fine with Astro v4 without any problem. @astrojs/mdx is having issues here.

Astro v4 + @astrojs/mdx v3 works as expected. So looks like a regression?

@surjithctly it will be fixed with the next patch of vite. As a workaround, avoid folders and files that contain spaces.

Request to keep this issue open since the issue still exists in this version even if's its an upstream issue. So tracking this will be easier.