Troubleshooting Next.js on Netlify

If you encounter issues running Next.js on Netlify, the information on this page may help you solve them.

# Troubleshooting large functions

You may see an error about generated functions being too large. This is because when deploying your site, it is packaged into a ZIP file. AWS limits ZIP files to 50 MB in size.

There are two possible causes for large ZIP files, each with a different solution. The list of largest files shown in the build logs will help you see what the cause is.

# Large dependencies

This is the most common root cause of generated functions being too large. Some node modules are very large, mostly those that include native modules. Examples include electron and chromium.

The function bundler is usually able to find modules that are actually used by your code, but sometimes it will incorrectly include unneeded modules. If this is the case, you can either remove the module from your dependencies if you installed it yourself, or exclude it manually in your netlify.toml.

[functions]
  included_files = ["!node_modules/A_LARGE_MODULE/**/*"]

In the above example, you should change the value to match the problematic module. The ! at the beginning of the module path indicates that it should be excluded.

If you do need large modules at runtime, you can try changing to a Netlify Function which has less overhead than the equivalent Next.js function.

# Netlify Support Forums

Can’t find what you’re looking for? The Netlify Support Forums are a great place to find more information and ask questions that are specific to your needs.