blomqma / next-rest-framework

Type-safe, self-documenting APIs for Next.js
https://next-rest-framework.vercel.app
Other
155 stars 20 forks source link

prettier can't resolve "module" #101

Closed SaadBazaz closed 11 months ago

SaadBazaz commented 11 months ago

Hello, Here's an issue I'm facing in recent release of NRF:

Screenshot 2023-11-12 at 15 17 59

It seems like prettier is importing something which breaks, "module", which results in all my requests failing.

Seems to be happening locally so far.

SaadBazaz commented 11 months ago

Once I run

yarn add module

I get error for 'stream'. Then I install stream, and I get error for 'constants'

Seems like node isn't being polyfilled correctly

SaadBazaz commented 11 months ago
Screenshot 2023-11-12 at 17 22 48
blomqma commented 11 months ago

Which Node.js version are you encountering this with? Unfortunately Node 18 is the oldest supported Node version currently with Next REST Framework.

SaadBazaz commented 11 months ago

Yep, I'm using v20.0.5 That might be the reason. Lemme downgrade to 18 LTS.

However, we should have support for latest versions, I don't see how that would be a huge issue so far.

SaadBazaz commented 11 months ago

Getting this error on Node 18.12.0 (LTS)

Screenshot 2023-11-13 at 09 46 56

Seems similar to the previous one.

SaadBazaz commented 11 months ago

The individual routes are working, but this error prevents the /api docs from loading.

Screenshot 2023-11-13 at 11 36 41
SaadBazaz commented 11 months ago

Which Node.js version are you encountering this with? Unfortunately Node 18 is the oldest supported Node version currently with Next REST Framework.

Can you tell me which exact node version it is? Tested it on 18.12.0 and 18.18.2, both didn't work

blomqma commented 11 months ago

Which Node.js version are you encountering this with? Unfortunately Node 18 is the oldest supported Node version currently with Next REST Framework.

Can you tell me which exact node version it is? Tested it on 18.12.0 and 18.18.2, both didn't work

Both 18.12 and 18.18.2 should work just fine. I need to investigate more to see if I can reproduce this. I you happen to have a public reproducible example, that would be great too.

blomqma commented 11 months ago

Haven't yet been able to reproduce this, but I've identified a potential reason/fix for this due to a module resolution issue with prettier. Could you try if this issue is fixed with v3.4.7, thanks!

SaadBazaz commented 11 months ago

Solved by upgrading Next Rest Framework, downgrading Node to 18, downgrading Next to 13.5.2, clearing node_modules, and deleting lockfile, then installing again.

Also solved by using nodejs runtime instead of edge runtime in some endpoints.