Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected ")" but found "22" (when running any new project) #5518

Closed
1 task
mohanadkandil opened this issue Dec 2, 2022 · 6 comments
Closed
1 task

Expected ")" but found "22" (when running any new project) #5518

mohanadkandil opened this issue Dec 2, 2022 · 6 comments
Labels
- P2: has workaround Bug, but has workaround (priority)

Comments

@mohanadkandil
Copy link

What version of astro are you using?

latest

Are you using an SSR adapter? If so, which one?

no

What package manager are you using?

npm

What operating system are you using?

windows 10

Describe the Bug

Whenever install just a simple new project using NPM or PNPM, I got this when I run pnpm/npm run dev

Expected ")" but found "22"
  File:
    D:/x/x/x/x/src/pages/index.astro:23:142
  Stacktrace:

Link to Minimal Reproducible Example

n/a

Participation

  • I am willing to submit a pull request for this issue.
@marcfielding1
Copy link

This doesn't provide any information anyone can help you with, can you show your index.astro please, or is it the default?

@Princesseuh
Copy link
Member

Princesseuh commented Dec 3, 2022

This happened because of a ' inside the project's file path, the user's folder was named Project '22/x/thing

@Princesseuh Princesseuh added the - P2: has workaround Bug, but has workaround (priority) label Dec 3, 2022
@JerryWu1234
Copy link
Contributor

This happened because of a ' inside the project's file path, the user's folder was named Project '22/x/thing

image

Why doesn't it happen on my side?

@Princesseuh
Copy link
Member

This happened because of a ' inside the project's file path, the user's folder was named Project '22/x/thing

image

Why doesn't it happen on my side?

Might only be happening on Windows perhaps?

@HiDeoo
Copy link
Member

HiDeoo commented Jan 16, 2023

I encountered the same issue on macOS with an Astro project created in a directory containing a single quote in its name, e.g. name'23.

After some investigations, this issue seems to be resolved in astro@2.0.0-beta.2 which upgrades the @astrojs/compiler to v0.32.0.

The issue was related to the output code by the compiler being similar to:

const $$Astro = $$createAstro(
	"/Users/hideo/Temp/astro/test'23/src/pages/index.astro",
	'',
	'file:///Users/hideo/Temp/astro/test'23/'
	//                                  ^ extra unescaped single quote
);

The last projectRoot path argument of the $$createAstro() call was containing the unescaped single quote of the directory name in a single quoted string, which is invalid code. This was not an issue for the file path as the string is double quoted.

The Astro version 2.0.0-beta.2 introduces changes from @bluwy to both the compiler and astro that removes the site and projectRoot options from $$createAstro() in favour of the astroGlobalArgs option, meaning the output code from the compiler is now similar to this:

const $$Astro = $$createAstro('https://astro.build');

This prevents the issue from happening.

@Princesseuh
Copy link
Member

@HiDeoo Thank you for investigating this! Even though it wasn't intended, it is wonderful that this got fixed.

I'll close this issue now, thank you everyone for reporting, helping and investigating this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority)
Projects
None yet
Development

No branches or pull requests

5 participants