hydrogen icon indicating copy to clipboard operation
hydrogen copied to clipboard

Fail to run preview

Open kyakaze opened this issue 3 years ago • 5 comments

Hi guys I had problems with deploying Hydrogen app to netlify, so I tried using the provided starter app. It did work on netlify, but when I ran preview on local, I ran into worker not found error.

image

I also manually ran npx @shopify/hydrogen-cli preview (v 0.12.1)and here is the error. image

I've tried with Node 16.5, 16.7 and 18. How do you guys successfully run preview? Thanks!!

kyakaze avatar Sep 01 '22 06:09 kyakaze

I'm also running into this same error, but a step behind you! I couldn't get the starter repo to work on Netlify (using a simple manual netlify deploy after checking out the repo). It errors out when loading. Did you do anything special to get it working?

jamosonic avatar Sep 01 '22 07:09 jamosonic

@jamosonic I just forked the starter app, then deployed on Netlify with github directly, there was no issue at all.

kyakaze avatar Sep 01 '22 09:09 kyakaze

Thanks for the tip. Clicked the deploy button in the readme instead and it worked 🙃. Weird!

jamosonic avatar Sep 01 '22 09:09 jamosonic

Note this line in the error thrown.

WorkerNotFoundError: A worker file is required for this command. Try building your project or check your mini-oxygen config file to ensure a workerFile is specified and the path is correct.

Try running build before preview as described below.

https://github.com/Shopify/hydrogen/tree/v1.x-2022-07/templates/demo-store#previewing-a-production-build

Does that work for you?

ramiroazar avatar Sep 02 '22 21:09 ramiroazar

@kyakaze @jamosonic if you are using the @netlify/hydrogen-platform plugin then the worker will not be created on build. Instead a .netlify/edge-functions directory will be created.

To preview your build locally, you can:

  1. Remove the netlifyPlugin() fron your vite.config.js plugins array (Please note that this will break your Netlify deploy)
  2. Install Netlify CLI and run netlify dev to mimic the Netlify Edge Function deployment locally

fergusfrl avatar Sep 05 '22 21:09 fergusfrl

pausing this PR as our release version need to be re-think

michenly avatar May 06 '24 14:05 michenly

Oxygen deployed a preview of your mc-changelog-update branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment May 8, 2024 2:48 PM
subscriptions ✅ Successful (Logs) Preview deployment Inspect deployment May 8, 2024 2:47 PM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment May 8, 2024 2:48 PM
vite ✅ Successful (Logs) Preview deployment Inspect deployment May 8, 2024 2:48 PM
optimistic-cart-ui ✅ Successful (Logs) Preview deployment Inspect deployment May 8, 2024 2:47 PM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment May 8, 2024 2:48 PM

Learn more about Hydrogen's GitHub integration.

shopify[bot] avatar May 07 '24 19:05 shopify[bot]