ForkMeDaddy
ForkMeDaddy•15mo ago

Cannot find module '@/convex/_generated/api'

I try to call this query inside an API route (app router) and running npx run devgives me a typescript error. however my IDE shows nothing wrong and I can even jump to the definition. What is the problem?
No description
No description
17 Replies
erquhart
erquhart•15mo ago
Did it work before and recently stop? Any chance the @ alias was added since the last time it worked
ForkMeDaddy
ForkMeDaddyOP•15mo ago
I think so. but was a while because I was away for some time
erquhart
erquhart•15mo ago
Try without the @, use a relative path and see if that works
ForkMeDaddy
ForkMeDaddyOP•15mo ago
okay this seems better but gives me another error 😄
ForkMeDaddy
ForkMeDaddyOP•15mo ago
No description
erquhart
erquhart•15mo ago
Node dropped support for __dirname, can't remember in which release oh that's in your dependencies if that error is coming from convex, it's expecting a node environment
ballingt
ballingt•15mo ago
@ForkMeDaddy what's the syntax of your import without the @
ForkMeDaddy
ForkMeDaddyOP•15mo ago
No description
ballingt
ballingt•15mo ago
import looks ok, this is now a runtime error — yeah agree with @erquhart this looks like you're using a library that expects Node.js. Do you know what library is using ua-parser? or can you share the user.js file?
erquhart
erquhart•15mo ago
It looks like it's from next - if you can share your node version and version of next that'd be helpful too
ForkMeDaddy
ForkMeDaddyOP•15mo ago
okay so the user file imports something that needs to run in a node environment that is causing the error can I define a convex function that guarantees that?
ballingt
ballingt•15mo ago
Any actions defined in convex/* files that have "use node"; as the first line will be bundled to run in Node.js instead.
ForkMeDaddy
ForkMeDaddyOP•15mo ago
oh awesome I will try it thx. didn't know that
ballingt
ballingt•15mo ago
however a file is only bundled for one environment or the other, so you might need to refactor if you have stuff in users.js that needs run in teh normal Convex JavaScript runtime (like mutations and queries)
safal007
safal007•11mo ago
I am having same problem. Everything working fine but suddenly stopped working.
No description
ballingt
ballingt•11mo ago
@safal007 you might be able to fix by adding these prefix path aliases from your main project tsconfig.json to you convex folder tsconfig.json, but the fir sure fix us not to use path aliases like @/convex/... We'll look at linting to suggest this fix
safal007
safal007•11mo ago
Thanks @ballingt

Did you find this page helpful?