erquhart
erquhart6mo ago

NoImportModuleInSchema

I've only seen this mentioned in one place in Discord, and nowhere else otherwise. I just finished the code migration from Clerk to Convex Auth and followed the docs pretty closely, and am now getting this when attempting to deploy (dev). Just to help me debug, can someone explain exactly what this error means, generically? I keep my table definitions in per-table files and import them all to schema.ts, and that has never been a problem. What are the things that can't be imported to the schema file?
5 Replies
erquhart
erquhartOP6mo ago
Also, would be amazing for this error to include some kind of reference as to the offending module.
ballingt
ballingt6mo ago
This is supposed to be accompanied by an error message: https://github.com/get-convex/convex-backend/blob/3f4e6443dc31a9e2ec9b2b746e806e8aa8cfbd24/crates/isolate/src/environment/schema.rs#L126-L127 This could be a circular import issue: typically importing like this shouldn't be required, instead the bundler should stick everything in one file with no imports These seem to happen in particular with schema, we might recommend a no-circular-imports eslint rule @erquhart if you can't see this error we've got an issue, could you screenshot what you see and I'll file an issue?
erquhart
erquhartOP6mo ago
checking now oh right, it does do that but the path is some post compilation file:
Can't import _deps/WAEWWB43.js while evaluating schema
Can't import _deps/WAEWWB43.js while evaluating schema
Tried the eslint rule to help debug, it pointed to some imports down the chain from convex/_generated:
import { DataModel, Doc, Id, TableNames } from './_generated/dataModel'
import { DataModel, Doc, Id, TableNames } from './_generated/dataModel'
But these have been there since before the auth migration. @ballingt even if I turn off schema validation, I still get this, even though it's a schema validation error. I've checked and the import changes are the same as demonstrated in the tutorial. Still debugging.
Error: Unable to run schema validation on https://<deployment>.convex.cloud
Error fetching POST https://<deployment>.convex.cloud/api/prepare_schema 400 Bad Request: NoImportModuleInSchema: Hit an error while evaluating your schema:
Can't import _deps/2RYCN62A.js while evaluating schema
Error: Unable to run schema validation on https://<deployment>.convex.cloud
Error fetching POST https://<deployment>.convex.cloud/api/prepare_schema 400 Bad Request: NoImportModuleInSchema: Hit an error while evaluating your schema:
Can't import _deps/2RYCN62A.js while evaluating schema
I stopped importing the tsx template for resend and moved on to a new error:
Uncaught Error: Environment variables unsupported when evaluating schema
Uncaught Error: Environment variables unsupported when evaluating schema
Which is explained here: https://discord.com/channels/1019350475847499849/1252573078848798721/1252574564479668236 I'm going to do what's needed to get a deployment out, but will then need to circle back to using Resend templates.
ian
ian6mo ago
Would it go away if you didn't import the auth tables in schema? That's the only schema import I can think of - unless some of your schema files are importing from auth.ts
erquhart
erquhartOP6mo ago
Lol literally just wrote "I will do almost anything to avoid moving my entire schema back to that one file." in another thread Did more troubleshooting in the other thread and that does seem to be the issue: https://discord.com/channels/1019350475847499849/1252573078848798721/1263567118213971990 This and the issues in the other thread seem to be one in the same. For anyone else running into this, if you're importing things into your schema, make sure you're not importing anything that is importing anything that is importing { convexAuth } from @convex-dev/auth/server. This can easily happen if you build your schema in other files and import it, because you'll probably add auth.getUserId() in one of those files while migrating to Convex Auth. I had to do a full on refactor to address this because I'm importing so much into my schema file.