- Published on
Fixing Vercel Build Error with .vercelignore
- Authors
- Name
- Ashik Nesin
- @AshikNesin
Sometimes you might need to write custom code and keep it in the same repo as your core Next.js app.
Everything may seem to work perfectly, but when you deploy on Vercel you might be greeted with an error message for code that isn't part of your Next.js application.
In such cases, you can use .vercelignore
Similar to .gitignore, create a new .vercelignore
file and list the directories or files you want Vercel to ignore during the build.
In my case, I ignored scripts/ingestion
by adding it to .vercelignore at the project root, which resolved the error.
If you're also facing ESLint issues, you can exclude that directory in your tsconfig.json:
{
"exclude": [
"node_modules",
"path/to/ignore/**/*"
]
}
That's pretty much it.
Hope this helps you resolve the issue as well.
Happy fixing issues!