Next.js Discord

Discord Forum

File path not found after deploying to Vercel

Unanswered
Sokoke posted this in #help-forum
Open in Discord
SokokeOP
Hello everyone,
I deployed a Next.js14 site to Vercel. I have a json file in the root of my project.
The file path works locally but once I deploy, I kept getting errors as a result of the file path in production.

Can anyone please point me to what I'm missing out in the file path?

5 Replies

Oriental chestnut gall wasp
I am also getting the same error post deployment to vercel, i am sure this is coz of serverless nature of Nextjs but not able to figured out the solution for it.
@Sokoke did you find anything on this ??
if it's a json file you can just import the file directly
// In TypeScript:
import data from "../../winners.json"
Northeast Congo Lion
When you deploy to Vercel, it doesn't copy your whole root. You need to use a plugin to have your builder copy the files you need to where you need them in the final build directory. I use webpack, and in my next.config.js I add the plugin copy-webpack-plugin and configure it to copy some files from my project root into the build output folder.