Replies: 30 comments 48 replies
-
I think the .next folder is for caching in development and stuff. If you wanted to see the file output of the production build run "next export" after build. |
Beta Was this translation helpful? Give feedback.
-
Hi. How can I fix this issue? |
Beta Was this translation helpful? Give feedback.
-
I encountered similar issue where the .next folder size is too large that fill up all my disk space on the server, making me unable to deploy new changes to the server via CI/CD. At the end I have to remove the folder and build manually. Is there any way that it could remove very old caches when running next build? |
Beta Was this translation helpful? Give feedback.
-
my .next folder is over 10gb that's wayy to big. |
Beta Was this translation helpful? Give feedback.
-
same problem here !!! its over 1.5 G after npm run build... |
Beta Was this translation helpful? Give feedback.
-
If anyone else is facing this problem, delete your .next folder before running npm run build. |
Beta Was this translation helpful? Give feedback.
-
i too have the same issue? is it ok to remove the dir .next/cache after build ? |
Beta Was this translation helpful? Give feedback.
-
Next.js can automatically create a standalone folder which copies only the necessary files for a production deployment including select files in |
Beta Was this translation helpful? Give feedback.
-
After running Weird, but as a temporary fix :/ |
Beta Was this translation helpful? Give feedback.
-
Hey everyone, any update on this issue? We are facing the same problem... is this a normal behaviour? We ended up building our app in standalone mode. But there is a lack of documentation on this Thanks for readings. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for all the comments in this discussion! I had an issue deploying my Next.js hybrid app to Azure Static Web Apps, because the cache folder in the build folder ended up taking 90% of the size, exceeding the > 100MB limit. By adding a removal for that folder, I managed to fix the deployment issue. Hopefully, there will be a more permanent solution to this in the context of automated deployments. |
Beta Was this translation helpful? Give feedback.
-
There seems to be no solution for this after more than two years of discussion. Can we at least have the cache size limited to a maximum and make it configurable? A coworker ended up with a size of 300GB+ just for the cache folder... My SSD is only 128GB... |
Beta Was this translation helpful? Give feedback.
-
SOLVED. So, as I wrote earlier, my cache folder took up about >= 7 GB in development mode. Option for webpack optimization
|
Beta Was this translation helpful? Give feedback.
-
I came across the same issue of a big .next/cache folder, and it was making my Docker image way too big. After searching a bit I found this answer, the cache folder is only used for building purposes and is not needed for production nor running the app in general it seems. |
Beta Was this translation helpful? Give feedback.
-
can anyone tell me how you are knowing your folder sizes?? |
Beta Was this translation helpful? Give feedback.
-
Upgrading from Next 11 to 14 here. What observation I see is build cache >1gb and thus Vercel can no longer cache it
On Next 11, my builds used to have 400mb cache. Now:
I have 1 function which is "server-rendered on demand using the Edge Runtime". Many others are on Node runtime. So why the near duplication between the edge-server-production and server-production cache folders? This also leads to build being slow, if webpack is building twice for every function, 1 for Edge and 1 for Node, regardless of how the api functions are actually deployed. So it's a double whammy, wasting build time and cache size (exceeding 1gb in my case) Can someone from Vercel / Next shed some light please |
Beta Was this translation helpful? Give feedback.
-
I have a 5+GB |
Beta Was this translation helpful? Give feedback.
-
this is because of the default cache created by the nextjs For Resolving FetchCache Issue You can add this at root export const fetchCache = 'no-store'
// same level as metaData and RootLayout
// or Adding revalidate of 10 second or 5 minutes ( 300 seconds )
export const revalidate = 300 For Solving issue of Image Cache add this in images: {
minimumCacheTTL: 86400
} |
Beta Was this translation helpful? Give feedback.
-
the .next file size increases every time npm run dev is performed. saw something about deleting the cache folder before deploying it, but the cache folder is just going to come back after you run your server again. it seems like there is no permanent solution of containing the cahce folder size in next 14 yet :( |
Beta Was this translation helpful? Give feedback.
-
you can just delete the .next/cache folder and then deploy it it works fine and the size is reduced from 1.2GB to 9.5MB and we are running it using PM2 on the live server without any issue. |
Beta Was this translation helpful? Give feedback.
-
So we dont need node_modules files right ? As that is also somewhat 500mb |
Beta Was this translation helpful? Give feedback.
-
I'm using a custom server, but unfortunately it's in standalone mode and server.js can't be tracked. https://nextjs.org/docs/pages/building-your-application/configuring/custom-server So I removed.next/cache and reduced the build cache by 1.5GB,But I can't remove the node_module, this my app dockerfile:
|
Beta Was this translation helpful? Give feedback.
-
I face the same issue it have reduced to 800mb but still I want to know if there is any quicky solution for this size issue
|
Beta Was this translation helpful? Give feedback.
-
I deploy to Vercel and get similar error: Reading at https://nextjs.org/docs/app/api-reference/config/next-config-js/output#caveats, about
Then the project working right, my nextjs version is |
Beta Was this translation helpful? Give feedback.
-
Step 1: Update your next.config.ts to this file import type { NextConfig } from 'next'; Step 2: install this package Step 3: replace you build script in package json |
Beta Was this translation helpful? Give feedback.
-
Opt1
Opt2
|
Beta Was this translation helpful? Give feedback.
-
Running into this problem too. Cache in dev grows to > 30GB over time. Changing my
automatically restarts the server once memory hits 4GB 🤷♂️ |
Beta Was this translation helpful? Give feedback.
-
Temporarily setting the build command in Vercel to |
Beta Was this translation helpful? Give feedback.
-
The reason is they have monopoly over React and SSR Framework. I think there are doing som technical tackticks with Technical peoples. I started with Next JS and moved to Remix and Because of these peoples. I tried on POC of Custom SSR rendering, It worked, so I Completed moved to React with Vite Build tool. You can also use Remix - but it has many issues at begining. Most of the times you do no need SSR. Go with React and Vite |
Beta Was this translation helpful? Give feedback.
-
I have a next js application running in production. I use app router and ISR to cache pages. After, for example, a month after deploying the app, the .next folder can take up tens of GB. The .next/server/app folder is mainly responsible for this size. Does anyone know what I could do to prevent this folder from reaching such a large size? I don't need next js to hold the page cache indefinitely. Could I for example delete files older than 3 days from it while the application is still running production without risking breaking the application? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm wondering if it's ok that my .next folder's size is 251MB.
I'm building with
target: serverless
, and after runningnpm run build
successfully, I looked into.next
folder and notice that every file in/pages
folder is ~4.5MB, also in/api
folder. There are files that are even ~10MB.Is it ok? Am I doing something wrong maybe?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions