Next.js Discord

Discord Forum

Deployment on Vercel Fail because of build... but build is good in local

Answered
Spectacled bear posted this in #help-forum
Open in Discord
Avatar
Spectacled bearOP
Hello,
I am desperate.
I want to put into production a NextJS project (web part of a Turborepo monorepo). Specificity: I use pnpm instead of npm.
The local build goes without worries, but during the production it gets me out of errors that do not make sense to me.
Attached screenshots

So I humbly ask for your help.
Image
Image
Image
Image
Answered by Spectacled bear
PS: I had to switch from pnpm to npm to make it work
View full answer

35 Replies

Avatar
Spectacled bearOP
It seems to me that this is related to the custom paths I have set up, the vercel build can’t find them, but on the IDE side the files contain no errors, the paths are good (crtl + click brings me to the right place, the pages work well in frontend, and the build command (identical to that used by Vercel deployment) passes without problem, and the tsconfig.json file seems correct too.
I really don’t know what to do... I can provide more information if needed
Avatar
Spectacled bearOP
Ty.
I'm still in trouble...
In ths case per exemple, case sensitivity seems good
Image
Image
Image
Avatar
Wow, now it looks weird. Is this the only one left or does the entire problem remain?
Avatar
Spectacled bearOP
I have this problem only for certains components/files
Image
Image
@joulev
my ts config file :
Image
Avatar
I see so the entire problem still persists after checking all path aliases and casing are correct
Avatar
Spectacled bearOP
yep
may be it's due to the monorepo... idk
or pnpm
Avatar
Spectacled bearOP
worst is one deployement was good ... idk why lol
Image
Avatar
Spectacled bearOP
Do you think change my package manager from pnpm to npm or yarn can make a difference ? @joulev
Avatar
I don’t think so, no. I use pnpm monospaces too and they work fine
Try this: instead of @components, use @/components
So basically add a slash
Update absolute imports and tsconfig.json accordingly
Avatar
Spectacled bearOP
🥲 (I re-tested build in local after changes, still work)
Image
Image
Image
Image
may be i did changes the wrong way idk
Stupid idea but: I know that I can’t have a folder called "types" at the root of the next folder because it conflicts with modules nodes. Similarly, it may be that these files pose a similar naming problem. But I would be surprised if I renamed them on purpose
@joulev
Avatar
Spectacled bearOP
Just saw that too :
(I had to use "corepack up" because I had errrors with all packages (2nd screenshot)
Idk if this can be part of the solution


web:build:  ELIFECYCLE  Command failed with exit code 1. web:build: ERROR: command finished with error: command (/vercel/path0/apps/web) /vercel/path0/.vercel/cache/corepack/shim/pnpm run build exited (1) web#build: command (/vercel/path0/apps/web) /vercel/path0/.vercel/cache/corepack/shim/pnpm run build exited (1) WARNING finished with warnings Warning - the following environment variables are set on your Vercel project, but missing from "turbo.json". These variables WILL NOT be available to your application and may cause your build to fail. Learn more at https://turbo.build/repo/docs/platform-environment-variables [warn] web#build [warn] - ENABLE_EXPERIMENTAL_COREPACK Tasks: 0 successful, 1 total Cached: 0 cached, 1 total Time: 18.53s Summary: /vercel/path0/.turbo/runs/2o77bwxIJF9oNniI5KzuBEW55Y5.json Failed: web#build ERROR run failed: command exited (1) Error: Command "turbo run build" exited with 1
Image
Image
Avatar
Now I’m really puzzled. The types folder shouldn’t matter. I’ll go home and try a bit
Avatar
Spectacled bearOP
I didn’t want to create any confusion. What I meant by the *types * folder was just that I had to rename it in a different way (type) because it interfered with the node_modules. However, my current problem does not seem to be related to this.
Thank you for your help anyway!
Avatar
Spectacled bearOP
I've tried many things but still same problem

Here's the full logs for a deployement.

I'm about to give up, and use another deployment tool, hoping that it will go better...

I have a defense for this project after tomorrow and I did not think to spend so much time deploying the frontend
Image
Avatar
Spectacled bearOP
I spent the previous 4 hours looking for a solution in vain. Do you have another track? thanks from advance @joulev
Avatar
Spectacled bearOP
After many many time i finally achieve to deploy my website...but still not working xd
Basically I have now a 404
So here's the infos

If you have any idea of why ahah
I through it can be env vars, but I tested on postman and it's OK
Image
Image
Image
Image
Image
Ty in advance
I go sleep
Avatar
Spectacled bearOP
PS: I had to switch from pnpm to npm to make it work
Answer
Avatar
now im genuinely confused since i just cloned your repo to a blank linux machine (the same OS that vercel uses) and it builds just fine
but looking at your commit history, looks like switching to npm did the trick, as weird as it sounds to me, so happy to see you fixing it and sorry i couldn't help much