Cannot find module '@/convex/_generated/api'
I try to call this query inside an API route (app router) and running
npx run dev
gives me a typescript error. however my IDE shows nothing wrong and I can even jump to the definition. What is the problem?

17 Replies
Did it work before and recently stop?
Any chance the
@
alias was added since the last time it workedI think so. but was a while because I was away for some time
Try without the
@
, use a relative path and see if that worksokay this seems better
but gives me another error 😄

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@ForkMeDaddy what's the syntax of your import without the
@

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?
It looks like it's from next - if you can share your node version and version of next that'd be helpful too
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?
Any actions defined in convex/* files that have
"use node";
as the first line will be bundled to run in Node.js instead.oh awesome
I will try it
thx. didn't know that
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)
I am having same problem. Everything working fine but suddenly stopped working.

@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
Thanks @ballingt