amplify-hosting
amplify-hosting copied to clipboard
NextJS 12 frontend build throws "No build cache found. Please configure build caching for faster rebuilds" warning
Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the FAQ.
- [X] I have searched for duplicate or closed issues.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
App Id
d2gl6gra9yo4lf
AWS Region
us-west-2
Amplify Hosting feature
Frontend builds
Describe the bug
NextJS 12 build cache does not seem to be working for me on AWS Amplify. I have a monorepo with the frontend hosted in a subdirectory, and my amplify.yml configuration looks like this:
version: 1
applications:
- frontend:
phases:
preBuild:
commands:
- nvm install 14
- nvm use 14
- yarn install
build:
commands:
- nvm use 14
- yarn run build:$BUILD_TYPE
test:
commands:
- nvm use 14
- yarn run test:$BUILD_TYPE
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- '.next/cache/**/*'
- 'node_modules/**/*'
appRoot: path/to/frontend
When I run a build, I see the following warning message in my frontend build logs:
warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
Expected behavior
I expect the build cache to be found.
Reproduction steps
- See the config above
Build Settings
No response
Log output
# Put your logs below this line
Additional information
No response
+1. Thought this was addressed per https://github.com/aws-amplify/amplify-hosting/issues/2436#issuecomment-1319187238 but the issue remains
up, anybody?
+1
+1
+2
Yeah, I'm also experiencing this on a time critical project..
same here
+1
+1
I switched over to Vercel. Much better experience
Likewise.
We switched over to Vercel a couple weeks ago after AWS Amplify broke our build (claiming our bundle size was suddenly several times over the limit on builds that built fine the day before). Their support team tried to blame it on us, and after going back and forth debugging with them for several days they finally acknowledged that it was an issue on their side and told us they had no short term fix for it.
I would not risk running any production NextJS application on AWS Amplify ever again after this experience. I know they have smart engineers and an over-worked support team that are trying their hardest to help us, but it is quite apparent that AWS as an organization is not investing in Amplify or treating it as a first-class product.
In terms of your other options:
- Vercel builds are significantly faster, all of NextJS' features that we use were supported with no issues, and their support is responsive and helpful. The migration required almost no code changes.
- We also explored CloudFlare Pages as an option and had our site building there without issues within a couple of hours as well.
- We looked at Netlify and Render but did not invest in getting our app to build on there once we had it working on the first two providers.
@LucasLemanowicz This exact issue just happened to us last night and I've been debugging ever since. Went from ~120MB to suddenly ~750MB build output with a single small code commit.
Glad to know I'm not alone.
+1
+1
+1
+1
+1
Is there any update here?
+1
+1
Hi everyone 👋 , we have updated our documentation with the following troubleshooting guide: https://docs.aws.amazon.com/amplify/latest/userguide/troubleshooting-ssr-deployment.html#build-output-too-large. This guide should enable you to:
- Download and inspect your build artifacts
- Analyze the
.next
directory and the buildcache
directory within it - Measure the size of your
compute
andstatic
directories - Review the dependencies within the
node_modules
folder - Delete the binaries that aren't required at runtime
Additionally, to improve build performance and to persist the cache between builds Amplify Hosting now adds the following cache paths by default to your buildSpec
:
cache:
paths:
- node_modules/**/* # Cache `node_modules` for faster `yarn` or `npm i`
- .next/cache/**/* # Cache Next.js for faster application rebuilds
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.
This issue has been automatically locked.