void
void•2y ago

👋 got my project working locally with

👋 got my project working locally with convex (nextjs 13 project) but my build/deployment fails on vercel. well, i should say it hangs. i followed the docs and have my env variables yet and custom build command to include npx convex deploy
27 Replies
void
voidOP•2y ago
Detected Next.js version: 13.2.0
Running "npx convex deploy && npm run build"
Detected Next.js project.
Detected Next.js version: 13.2.0
Running "npx convex deploy && npm run build"
Detected Next.js project.
it gets this far and has been running for about 10 min 😦
nipunn
nipunn•2y ago
eee. Just as a sanity check - does the npx convex deploy command work if you run it locally? Also npm run build ?
void
voidOP•2y ago
yes and yes actually that's not true sorry
nipunn
nipunn•2y ago
Good stuff getting everything working together btw! Let's figure out how to get it deployed for the last step
void
voidOP•2y ago
Type error: Module '"convex/schema"' has no exported member 'defineSchema'. Did you mean to use 'import defineSchema from "convex/schema"' instead?

> 1 | import { defineSchema, defineTable, s } from "convex/schema";
| ^
2 |
3 | export default defineSchema({
4 | tles: defineTable({
Type error: Module '"convex/schema"' has no exported member 'defineSchema'. Did you mean to use 'import defineSchema from "convex/schema"' instead?

> 1 | import { defineSchema, defineTable, s } from "convex/schema";
| ^
2 |
3 | export default defineSchema({
4 | tles: defineTable({
i think i might need tro make a change to my tsconfig for next
nipunn
nipunn•2y ago
let me pull in my bud @ballingt - I think he might have context here.
void
voidOP•2y ago
my favorite guy
nipunn
nipunn•2y ago
me too
void
voidOP•2y ago
tom makes the world go round yeah i think that's the problem "exclude": ["node_modules", "convex"] forgot to add this i think damn nevermind i have that here too
nipunn
nipunn•2y ago
So someone else ran into this problem yesterday https://discord.com/channels/1019350475847499849/1019350478817079338/1078127155306827828 - which may or may not be relevant. Where we were seeing some issue with typescript not finding schema.ts but only when using next But the symptoms are subtly different, so I'm not 100% sure Check if baseUrl is in your typescript template and if the "fix" that they talked about in that thread helps.
void
voidOP•2y ago
huh interesting; changing the convex/ directory to anything but convex? i do indeed have: "baseUrl": ".",
sshader
sshader•2y ago
My understanding is that "baseUrl": "." causes TypeScript to resolve imports for convex/schema as a path relative to your project instead of the Convex npm package (so it can't find defineSchema because presumably you're not defining that in your own convex/schema.ts file).
void
voidOP•2y ago
okay renaming things also fixed my issue
sshader
sshader•2y ago
So naming your convex directory to convex-foo or basically anything else should mean that the convex/schema import in your convex-foo/schema.ts file resolves to our npm package 🤞
void
voidOP•2y ago
did something change recently in a new version of TS or something? this was working a couple weeks ago but did just update npm packages at least npm run build works; seeing if my deployment goes any further deployment still hangs at "Detected Next.js project." going to take a break; spent an hour trying to compare differences between a working deployment and this
nipunn
nipunn•2y ago
Our friend Tom filed this against Next https://github.com/vercel/next.js/issues/46288 - and has a hypothesis that it might be a january regression
GitHub
baseUrl in create-next-app causes local files to shadow npm package...
Verify canary release I verified that the issue exists in the latest Next.js canary release Provide environment information tomb@Thomass-MacBook-Pro-2 abcef % npx --no-install next info Operating S...
ballingt
ballingt•2y ago
OK the "Detected Next.js project." might be trying to prompt to offer to save an environment variable We should at least detect CI and not offer in those cases
void
voidOP•2y ago
could i temporarily put in the convex url variable? to skip the prompt?
ballingt
ballingt•2y ago
@void yeah! There's a flag --no-save-url I want to see if this is also what @andresBeltran is hitting when they're back online
void
voidOP•2y ago
so i'd have to probably use the flag in the build command and add the URL in environment variables right? not one or the other?
ballingt
ballingt•2y ago
We need to change it to be one or the other but yes right now it just checks .env for NEXT_PUBLIC_CONVEX_URL or whatever and not the actual environment
void
voidOP•2y ago
hmm okay tried deploying after just setting NEXT_PUBLIC_CONVEX_URL in all envs in vercel dashboard; redeployed and still got same error changed build command to include --no-save-url and redeployed then got this far:
void
voidOP•2y ago
No description
void
voidOP•2y ago
ill keep diggin 🤓 idk if it matters but it looks like it's always deploying to prod convex even tho im in a vercel preview env dev branch
ballingt
ballingt•2y ago
that is interesting (and we should change that!) ok "unable to build indexes" is interesting
ballingt
ballingt•2y ago
This has been fixed in Next.js! https://github.com/vercel/next.js/pull/46458 If you started a project with a Next.js template between Jan 6 2023 and whenever the next Next.js release is you'll still see this issue, you can make the change manually by deleting baseUrl: "." from the tsconfig.json. As seen above, another workaround is to change the name of the convex/ directory by moving it changing the corresponding line in convex.json.
GitHub
Remove baseUrl from create-next-app ts/jsconfig.json by thomasballi...
Fixes #46288 Makes TypeScript behavior match runtime by no longer allowing files to be imported absolutely relative to project root without using a relative path or a path alias. This changes behav...
void
voidOP•2y ago
sweet thanks updated next and renamed back to convex/ , removed baseUrl and we're golden 🙂

Did you find this page helpful?