Dhravya / cloudflare-saas-stack

Quickly make and deploy full-stack apps with database, auth, styling, storage etc. figured out for you. Add all primitives you want.
2.94k stars 210 forks source link

Cannot read properties of undefined reading "default" error on Windows when running project locally #15

Closed Vette1123 closed 1 week ago

Vette1123 commented 1 month ago

I followed your steps regarding how to run the project, but i keep getting this error

image

Dhravya commented 1 month ago

I remember getting that once. Can you try deleting node_modules, installing dependencies again, and running the web app in apps/web?

cd apps/web bun run dev

Vette1123 commented 1 month ago

image

same issue

leestreetnet commented 1 month ago

Getting same error, tried deleting node_modules to no avail.

I believe it's from the const usr = await auth() line in app/page.tsx - I logged usr and it returns a null value.

Windows OS

Dhravya commented 1 month ago

hmm, that should be fine tbh, @Vette1123 what operating system are you on?

Vette1123 commented 1 month ago

hmm, that should be fine tbh, @Vette1123 what operating system are you on?

Windows 11

jfortez commented 1 month ago

same

Dhravya commented 1 month ago

maybe I'm unable to reproduce because I'm running on a Mac.

I'm pretty sure this is a bun-related issue. can someone try using npm / pnpm ?

Dhravya commented 1 month ago

Also, does anyone know why this is the case for windows? https://github.com/Dhravya/cloudflare-saas-stack/issues/11

Vette1123 commented 1 month ago

Also, does anyone know why this is the case for windows? #11

I haven't got this error, i tried running the script, also manual setup, i only faced the issue mentioned here, haven't got the account id issue

but thanks for your response, will try different package manager and let you know

leestreetnet commented 1 month ago

ran npm run dev in both root and apps/web directory, still same issue

Dhravya commented 1 month ago

Can you share the apps/web/wrangler.toml file?

Vette1123 commented 1 month ago

image

jfortez commented 1 month ago

name = "cloudflare-saas-starter" compatibility_date = "2024-03-29" compatibility_flags = [ "nodejs_compat" ] pages_build_output_dir = ".vercel/output/static"

[placement] mode = "smart"

[[d1_databases]] binding = "DATABASE" database_name = "cf-app-db" database_id = "a6a433d1-3b7e-40ab-a322-f14cb8566d4c"

Vette1123 commented 1 month ago

@Dhravya switched to pnpm and still same error image

Dhravya commented 1 month ago

@Vette1123 did you also install dependencies using pnpm?

Vette1123 commented 1 month ago

@Vette1123 did you also install dependencies using pnpm?

yea,

whistle-dev commented 1 month ago

image

I get this straight from setup and bun run dev

paulls597 commented 1 month ago

I'm lost I don't even know what I'm looking at! I'm just on this site so I can look like I'm doing something important in front of my girlfriend.

Dhravya commented 1 month ago

paul, tell your girlfriend that i said hi

to others: this is a bug in wrangler - fixing!

Vette1123 commented 1 month ago

paul, tell your girlfriend that i said hi

to others: this is a bug in wrangler - fixing!

any news?

Vette1123 commented 1 month ago

image

ioabhishek commented 1 month ago

getting the same error image

i tried setting up next project outside without turbo and it worked fine but when cloning the same repo inside turbo getting this issue image

with turborepo its not working

ioabhishek commented 1 month ago

paul, tell your girlfriend that i said hi

to others: this is a bug in wrangler - fixing!

Hey did you got any fix for this

Vette1123 commented 1 month ago

getting the same error image

i tried setting up next project outside without turbo and it worked fine but when cloning the same repo inside turbo getting this issue image

with turborepo its not working

i solved default error by deleting

export const runtime = 'edge' from page.tsx file

but i was still getting prepare issue as the picture i attached above (it was something wrong with d1, cloudlfrare, wrangler), i swithced to turso and its working fine now, at least until cloudflare errors get solved for windows

ioabhishek commented 1 month ago

but if we will remove this export const runtime = 'edge' then nextauth adapter will not work i think so

Vette1123 commented 1 month ago

but if we will remove this export const runtime = 'edge' then nextauth adapter will not work i think so

it will, give it a try.

auth.js supports both edge and node runtime

ioabhishek commented 1 month ago

not able to figure it out, working fine in a plain next js app but cloning the same in turborepo is giving error

codingforfoodllc commented 1 month ago

getting this error as well.

jivjen commented 1 month ago

Yup same error for me as well on windows. Any possible workaround for this yet?

jivjen commented 1 month ago

@codingforfoodllc @ioabhishek @leestreetnet @Vette1123 @paulls597 @jfortez @leestreetnet @Dhravya After some intense trial and error I have found a fix for this issue. Go to app/web/package.json and make it "dev": "next dev --turbo" And this resolves the D1 connectivity issue and the inital error.

Later I faced some error related to the auth call and stuff made inside page.tsx

⨯ Error: headers was called outside a request scope

and that is coz next auth 5.0.0-beta.19 is not really in good terms with --turbo apparently lol (https://github.com/nextauthjs/next-auth/issues/11076) So I specified the version like this "next-auth": "5.0.0-beta.18" instead of "next-auth": "^5.0.0-beta.18" and now everything works like a charm. Also reminder to ditch windows asap! xD

leestreetnet commented 1 month ago

@jivjen thanks for --turbo fix!

Hitting the headers error now and the 5.0.0-beta18 change didn't fix for me unfortunately. I'll spend some time testing too.

jivjen commented 1 month ago

@leestreetnet Try deleting node_modules and package-lock.json from the directories and do a fresh install. Hopefully that should resolve it.

leestreetnet commented 1 month ago

@jivjen this worked - appreciate you

Anyone working on Windows and running into these issues, @jivjen solution worked for me.

Aunchers commented 1 month ago

@jivjen You are amazing.