Remix and Vite - 2 error(s) and 0 warning(s) when compiling Worker.

I am trying to use pages for the first time and having an issue when trying to deploy. Working locally, everything works as expected but when building and running I get the error: 2 error(s) and 0 warning(s) when compiling Worker. This is for:
10:06:22.426 ✘ [ERROR] Could not resolve "crypto"
10:06:22.426
10:06:22.426 ../node_modules/cookie-signature/index.js:5:21:
10:06:22.426 ✘ [ERROR] Could not resolve "crypto"
10:06:22.426
10:06:22.426 ../node_modules/cookie-signature/index.js:5:21:
and:
10:06:22.428 ✘ [ERROR] Could not resolve "stream"
10:06:22.428
10:06:22.428 ../node_modules/stream-slice/index.js:3:24:
10:06:22.428 ✘ [ERROR] Could not resolve "stream"
10:06:22.428
10:06:22.428 ../node_modules/stream-slice/index.js:3:24:
I am using the template provided by Cloudflare, I have added the compatibility flag "nodejs_compat" and this is my dependencies:
"dependencies": {
"@heroicons/react": "^2.1.5",
"@prisma/client": "^5.17.0",
"@remix-run/cloudflare": "^2.10.3",
"@remix-run/cloudflare-pages": "^2.10.3",
"@remix-run/react": "^2.10.3",
"@tailwindcss/forms": "^0.5.7",
"bcryptjs": "^2.4.3",
"isbot": "^4.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"remix-auth": "^3.7.0",
"remix-auth-form": "^1.5.0"
},
"dependencies": {
"@heroicons/react": "^2.1.5",
"@prisma/client": "^5.17.0",
"@remix-run/cloudflare": "^2.10.3",
"@remix-run/cloudflare-pages": "^2.10.3",
"@remix-run/react": "^2.10.3",
"@tailwindcss/forms": "^0.5.7",
"bcryptjs": "^2.4.3",
"isbot": "^4.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"remix-auth": "^3.7.0",
"remix-auth-form": "^1.5.0"
},
I'm not sure how to fix this, as the guidance seems to be setting your compatibility flag, which I have done in wrangler.toml: compatibility_flags = [ "nodejs_compat" ] Any help would be appreciated!
3 Replies
Dan 👍
Dan 👍5mo ago
I won't be much help other than to say I was about to post the exact same problem today 😅 although I've got 19 errors of similar nature 👀
jordan
jordanOP5mo ago
I had quite a few as well, then I added the wrangler.toml part but these two won't go away. I've always tried to change the compatibility_date to see if that would make a different but it did not :/ I don't think I've done anything too out of the ordinary either. I've followed the remix-auth docs and added prisma and tailwind, so I'm quite confused by the issues I have. I noticed not everything was up to date, so I've updated all my dependencies but still get the same error. I ran npm ls crypto and npm ls stream and have no dependencies relying on this, so I'm not sure what the next steps are 😅 @Dan 👍 and anyone else who might get stuck... I got help on the Remix discord and my issue was I am importing from remix-node instead of cloudflare. I was doing auth and had: import { createCookieSessionStorage } from "@remix-run/node"; Instead of: import { createCookieSessionStorage } from "@remix-run/cloudflare"; Have a look through your code and make sure you import from @remix-run/cloudflare for anything node related.
Dan 👍
Dan 👍5mo ago
Interesting, thanks mate. I just had a quick look I suspect it was some mdx package for me.
Want results from more Discord servers?
Add your server