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

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

Closed
Vette1123 opened this issue Jul 23, 2024 · 34 comments

Comments

@Vette1123
Copy link

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

image

@Dhravya
Copy link
Owner

Dhravya commented Jul 23, 2024

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
Copy link
Author

image

same issue

@leestreetnet
Copy link

leestreetnet commented Jul 23, 2024

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
Copy link
Owner

Dhravya commented Jul 23, 2024

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

@Vette1123
Copy link
Author

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

Windows 11

@jfortez
Copy link

jfortez commented Jul 23, 2024

same

@Dhravya
Copy link
Owner

Dhravya commented Jul 23, 2024

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
Copy link
Owner

Dhravya commented Jul 23, 2024

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

@Vette1123
Copy link
Author

Vette1123 commented Jul 23, 2024

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
Copy link

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

@Dhravya
Copy link
Owner

Dhravya commented Jul 23, 2024

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

@Vette1123
Copy link
Author

image

@jfortez
Copy link

jfortez commented Jul 23, 2024

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
Copy link
Author

@Dhravya switched to pnpm and still same error
image

@Dhravya
Copy link
Owner

Dhravya commented Jul 23, 2024

@Vette1123 did you also install dependencies using pnpm?

@Vette1123
Copy link
Author

@Vette1123 did you also install dependencies using pnpm?

yea,

@Dhravya Dhravya changed the title Can't run the project Cannot read properties of undefined reading "default" error on Windows when running project locally Jul 23, 2024
@whistle-dev
Copy link

image

I get this straight from setup and bun run dev

@paulls597
Copy link

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
Copy link
Owner

Dhravya commented Jul 25, 2024

paul, tell your girlfriend that i said hi

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

@Vette1123
Copy link
Author

paul, tell your girlfriend that i said hi

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

any news?

@Vette1123
Copy link
Author

image

@ioabhishek
Copy link

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
Copy link

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
Copy link
Author

Vette1123 commented Jul 27, 2024

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
Copy link

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

@Vette1123
Copy link
Author

Vette1123 commented Jul 27, 2024

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
Copy link

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

@codingforfoodllc
Copy link

getting this error as well.

@jivjen
Copy link

jivjen commented Jul 29, 2024

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

@jivjen
Copy link

jivjen commented Jul 29, 2024

@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 (nextauthjs/next-auth#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
Copy link

@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
Copy link

jivjen commented Jul 29, 2024

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

@leestreetnet
Copy link

@jivjen this worked - appreciate you

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

@Aunchers
Copy link

Aunchers commented Aug 5, 2024

@jivjen
You are amazing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants