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

Template Project Project Doesn't Run At All - Parse failure: Unexpected token At file: /node_modules/@astrojs/image/dist/lib/get-image.js #8 #7996

Closed
1 task
stephan0x opened this issue Aug 8, 2023 · 3 comments
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: image Related to the `@astrojs/image` package (scope)

Comments

@stephan0x
Copy link

What version of astro are you using?

2.8.0

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

None

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Chrome, Firefox, Safari

Describe the Bug

Hi,

Have cloned this entire project: https://github.com/mhyfritz/astro-landing-page

Run the commands:
npm install

npm run dev

Visiting http://localhost:3000/

I receive the following error message on the webpage:

Error An error occurred. Parse failure: Unexpected token (81:70) At file: /node_modules/@astrojs/image/dist/lib/get-image.js Contents of line 81: const isDev = (_b = (Object.assign(import.meta.env,{_:process.env._,-:process.env.-,SSR:true,}))) == null ? void 0 : _b.DEV;

And the following error message on terminal
`
Parse failure: Unexpected token (81:70)
At file: /node_modules/@astrojs/image/dist/lib/get-image.js
Contents of line 81: const isDev = (b = (Object.assign(import.meta.env,{:process.env._,-:process.env.-,SSR:true,}))) == null ? void 0 : b.DEV;
Parse failure: Unexpected token (81:70)
At file: /node_modules/@astrojs/image/dist/lib/get-image.js
Contents of line 81: const isDev = (b = (Object.assign(import.meta.env,{:process.env.
,-:process.env.-,SSR:true,}))) == null ? void 0 : b.DEV; (x2)
7:13:10 pm [vite] Error when evaluating SSR module /node_modules/@astrojs/image/dist/index.js: failed to import "/node_modules/@astrojs/image/dist/lib/get-image.js"
|- Error: Parse failure: Unexpected token (81:70)
At file: /node_modules/@astrojs/image/dist/lib/get-image.js
Contents of line 81: const isDev = (b = (Object.assign(import.meta.env,{:process.env.
,-:process.env.-,SSR:true,}))) == null ? void 0 : _b.DEV;
at ssrTransformScript (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53776:15)
at ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53751:12)
at Object.ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:63307:20)
at loadAndTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53422:24)

7:13:10 pm [vite] Error when evaluating SSR module /node_modules/@astrojs/image/components/Image.astro: failed to import "/node_modules/@astrojs/image/dist/index.js"
|- Error: Parse failure: Unexpected token (81:70)
At file: /node_modules/@astrojs/image/dist/lib/get-image.js
Contents of line 81: const isDev = (b = (Object.assign(import.meta.env,{:process.env._,-:process.env.-,SSR:true,}))) == null ? void 0 : _b.DEV;
at ssrTransformScript (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53776:15)
at ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53751:12)
at Object.ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:63307:20)
at loadAndTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53422:24)

7:13:10 pm [vite] Error when evaluating SSR module /node_modules/@astrojs/image/components/index.ts: failed to import "/node_modules/@astrojs/image/components/Image.astro"
|- Error: Parse failure: Unexpected token (81:70)
At file: /node_modules/@astrojs/image/dist/lib/get-image.js
Contents of line 81: const isDev = (b = (Object.assign(import.meta.env,{:process.env._,-:process.env.-,SSR:true,}))) == null ? void 0 : _b.DEV;
at ssrTransformScript (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53776:15)
at ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53751:12)
at Object.ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:63307:20)
at loadAndTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53422:24)

7:13:10 pm [vite] Error when evaluating SSR module /src/components/hero-image.astro: failed to import "/node_modules/@astrojs/image/components/index.ts"
|- Error: Parse failure: Unexpected token (81:70)
At file: /node_modules/@astrojs/image/dist/lib/get-image.js
Contents of line 81: const isDev = (b = (Object.assign(import.meta.env,{:process.env._,-:process.env.-,SSR:true,}))) == null ? void 0 : _b.DEV;
at ssrTransformScript (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53776:15)
at ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53751:12)
at Object.ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:63307:20)
at loadAndTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53422:24)

7:13:10 pm [vite] Error when evaluating SSR module /src/components/footer.astro: failed to import "/src/components/hero-image.astro"
|- Error: Parse failure: Unexpected token (81:70)
At file: /node_modules/@astrojs/image/dist/lib/get-image.js
Contents of line 81: const isDev = (b = (Object.assign(import.meta.env,{:process.env._,-:process.env.-,SSR:true,}))) == null ? void 0 : _b.DEV;
at ssrTransformScript (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53776:15)
at ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53751:12)
at Object.ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:63307:20)
at loadAndTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53422:24)

7:13:10 pm [vite] Error when evaluating SSR module /Users/tehnoob/Documents/Work/HiTehnoob/astro-2/src/pages/index.astro: failed to import "/src/components/footer.astro"
|- Error: Parse failure: Unexpected token (81:70)
At file: /node_modules/@astrojs/image/dist/lib/get-image.js
Contents of line 81: const isDev = (b = (Object.assign(import.meta.env,{:process.env._,-:process.env.-,SSR:true,}))) == null ? void 0 : _b.DEV;
at ssrTransformScript (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53776:15)
at ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53751:12)
at Object.ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:63307:20)
at loadAndTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53422:24)

error Parse failure: Unexpected token (81:70)
At file: /node_modules/@astrojs/image/dist/lib/get-image.js
Contents of line 81: const isDev = (b = (Object.assign(import.meta.env,{:process.env._,-:process.env.-,SSR:true,}))) == null ? void 0 : b.DEV;
Error: Parse failure: Unexpected token (81:70)
At file: /node_modules/@astrojs/image/dist/lib/get-image.js
Contents of line 81: const isDev = (b = (Object.assign(import.meta.env,{:process.env.
,-:process.env.-,SSR:true,}))) == null ? void 0 : _b.DEV;
at ssrTransformScript (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53776:15)
at ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53751:12)
at Object.ssrTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:63307:20)
at loadAndTransform (file:///Users/tehnoob/Documents/Work/HiTehnoob/astro-2/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53422:24)`

Was really excited to work with this but I can't even get the project to load on vanilla.

What's the expected result?

The project runs and loads the page without fault

Link to Minimal Reproducible Example

https://stackblitz.com/github/mhyfritz/astro-landing-page

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 8, 2023
@natemoo-re natemoo-re added the pkg: image Related to the `@astrojs/image` package (scope) label Aug 8, 2023
@natemoo-re
Copy link
Member

The @astrojs/image package has been replaced by the astro:assets feature, so I'm not sure we'll be able to prioritize this bug. Please see this guide to update your code. I also left a comment on mhyfritz/astro-landing-page#8 to request that the template be updated.

@natemoo-re
Copy link
Member

It actually seems like this might be an issue with your process.env variables? Seems like you have values named - and _ in your path which is breaking our env handling.

@natemoo-re natemoo-re added the - P3: minor bug An edge case that only affects very specific usage (priority) label Aug 8, 2023
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Aug 8, 2023
@matthewp
Copy link
Contributor

@astrojs/image has been removed from Astro. You should begin migrating over to astro:assets instead which is our Image component going forward. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: image Related to the `@astrojs/image` package (scope)
Projects
None yet
Development

No branches or pull requests

3 participants