Next.js Discord

Discord Forum

Building on production but not on preview

Answered
Aleutian Tern posted this in #help-forum
Open in Discord
Aleutian TernOP
I'm able to build on main branch (production environment) but not on dev branch (preview) even though they are on the same commit 🤔
Any idea why?
I'm able to build just fine locally
Answered by Marchy
It looks like you're also using Bun, which isn't supported with next.js yet because it uses node APIs not supported by bun. You can use it for local dev, but it shouldn't be used for prod builds
View full answer

15 Replies

Aleutian TernOP
The env variables are the same
Is there a way to clear the build cache?
After a data purge, the build is also failing on main for another weird reason..
A pages error even though I'm using app router, what's going on today?
Everytime I redeploy I get a random error, still on main, same commit
Is next@canary not well supported on Vercel?
Aleutian TernOP
@Aleutian Tern Is next@canary not well supported on Vercel?
next@canary is the experimental branch
@Aleutian Tern After a data purge, the build is also failing on `main` for another weird reason..
It looks like you're also using Bun, which isn't supported with next.js yet because it uses node APIs not supported by bun. You can use it for local dev, but it shouldn't be used for prod builds
Answer
Aleutian TernOP
The same happens on next@latest
I tried with pnpm aswell
And next has a node shebang so bun run build still runs node 🤔
Plus, using the exact same commit, the same bun version (1.0.6), everything builds fine locally, and on vercel on the other environment
I even tried to redeploy the last successful deploy of the dev branch, which failed this time
@Marchy It looks like you're also using Bun, which isn't supported with next.js yet because it uses node APIs not supported by bun. You can use it for local dev, but it shouldn't be used for prod builds
btw bun package manager != using bun as environment for this case...
but as they are using it for build script too, i can see the problem there
Aleutian TernOP
You're right, the issue might be bun install
Aleutian TernOP
Somehow bun install behaves differently on Vercel than on my machine, even with --frozen-lockfile :/