Failed Deployment
Similar to this post: https://discord.com/channels/595317990191398933/1236032759923736668
I have tried deploying in vain, the deploy succeeds when using
npm run deploy
but ultimately fails with no logs or indication of the is causing the problem.
The deployment id for the last deploy is 554ebc67-f85b-433f-8e65-9a9a53ea0259
25 Replies
Hey there! It looks like we've got a
edge_deployment_failed
error with the following output.
How do I fix this? I have added the nodejs_compat compatibility flags?
you'll want that require to be an import, esbuild doesn't support dynamic requires. Sadly that looks to be in remix's code
The require is from a third party package,
dotenv
. Which I am using to get the keys for my CF-Turnstile
widget../node_modules/@remix-run/node/dist/sessions/fileStorage.jslooks like it's in remix not dotenv but either way, it looks like this wouldn't work anyway as it's trying to use files (fs) can you switch to a different session storage? they have a built-in
createWorkersKVSessionStorage
but you can also use like cookieI'm guessing that this is being cause by
Turnstile
likely for the proof of space mechanism it uses?turnstile isn't using remix nor sessions
remix is a web framework
Seems like you're using it + auth sessions backed by file storage
I'm not using any of that. I used CF template for remix. The website is super simple, an info page and a contact form. The contact form has Turnstile on it. I'm guessing that because of SSR, it is causing Turnstile to do stuff on the server which should only be done on the client.
This has nothing to do with turnstile, it's just the way remix is setup
Note that, in order for it to deploy in my console with wrangler I needed to go and manually add the
node:
prefix to the require in the dotenv
, cookiesignature
and `stream-slice
packages.sounds like a lot of node dependencies haha
Not sure if dotenv works in Workers since that usually loads from .env - no fs in Workers. You should have those in .dev.vars or wrangler.toml
yeah ^
You'll have to de-nodeify this project
That is likely the problem. I was basing myself on this post:
https://www.jacobparis.com/content/remix-cloudflare-pages
Jacob Paris
Deploy a new Remix app to Cloudflare Pages
Cloudflare doesn't use Node.js. Use wrangler as your dev server. Use .dev.vars instead of .env. Make sure you set up wrangler.toml correctly.
How? Are there an resources?
ah ok, that's trying to use dotenv in a node env there (vite dev server)
I'm using the wrangler dev server. So I'm basically mixing the two things up?
I'm not sure Remix's official guidance these days, that guide is using vite dev to build the files and then wrangler dev to just handle running them
This is my current build script:
I'm clearly using vite to build, which I guess is wrong. So how should this look?
Seems fine to me, interesting you needed to use dotenv, are you importing it in your code not just vite config?
I don't know that I "needed to use dotenv" as I said I was blindly following the blog.
So I replaced
dotenv
by using context in my loader
, action
functions in remix, and that provides me access to the vars. I have to clean out all the node stuff and try to deploy again.
I removed dotenv
and reinstalled the packages and then tried to re-deploy and I'm left with:
yeah so can you also avoid these two packages haha
I found the problem. I was re-using code from another project and it was importing from
@remix-run/node
. Fixed it to be from @remix-run/cloudflare
and it solved the issue. It's working now! Thanks for your helpπDoes someone has the fix for SvelteKit for this problem. I am still getting Could not resolve "crypto" using the cloudflare adapter.
Thank you! Just had the exact same issue and was struggling to figure out what the problem was