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

Next.Js 15, fs error #1142

Closed
maxpowernz opened this issue Nov 19, 2024 · 6 comments · Fixed by #1144
Closed

Next.Js 15, fs error #1142

maxpowernz opened this issue Nov 19, 2024 · 6 comments · Fixed by #1144

Comments

@maxpowernz
Copy link

Followed the react instructions using NextJs and getting node filesystem errors, assume the imports are not working correctly somewhere.

./node_modules/.pnpm/signaldb@0.22.0/node_modules/signaldb/dist/index.mjs

await (await import("fs")).promises.writeFile(t, n(l));

I was just browsing the library and this was the first experience with it. I don't have time to debug, but not a good first impression.

Cheers.

@maxnowack
Copy link
Owner

maxnowack commented Nov 19, 2024

Hi @maxpowernz, could you please post the full log output where the error occurs? I'll take a look into it.
The examples in this repository are also using next@15, so it's probably not a general issue with this setup.

@maxnowack
Copy link
Owner

Fix released with v0.23.0 🎉

@maxpowernz
Copy link
Author

maxpowernz commented Nov 20, 2024

Hi Max, was completely my fault sorry, I wasn't resolving the fs in the next.config file. But, I switched to using --turbo (npm run --turbo) and that configuration is no longer needed with turbo, and turbo pack is super fast. Also dont need to dynamic import the index file either. Oh, and I am using react 19 too.
Cheers.

@maxnowack
Copy link
Owner

No worries! 🙂

@maxpowernz
Copy link
Author

Just a thought though, wouldnt it be better to warn rather than throw error if it does detect browser and not use fs at all?

@maxnowack
Copy link
Owner

I think if we just warn, we have to have a fallback behavior. I'm not sure what's most intuitive.
Automatically use local storage? Not perform persistence at all?

Throwing the error is the most explicit and lets the user decide what to do. This error doesn't occur often either.

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

Successfully merging a pull request may close this issue.

2 participants