aws-amplify / aws-amplify/amplify-hosting
Why cache node_modules when prebuild command is "npm ci"?
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
When deploying an CRA or Next.js frontend to Amplify, the default configuration includes a prebuild command `npm ci` and cache path `node_modules/**/*`.
````yaml
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
# other stuff
cache:
paths:
- node_modules/**/*
````
However, as far as I know, `npm ci` clears `node_modules` and installs everything from scratch, which means Amplify spends time caching dependencies after each build that will simply be discarded on the next build, rendering the caching unnecessary.
Am I mistaken about this, or would it be better — and faster — to use `npm install` or just to not cache `node_modules` at all?
Contributor guide
Research direction
Start by checking the default Amplify build configuration for CRA and Next.js and verifying what npm ci does to node_modules. Done means determining whether the configured cache is useful and identifying whether the default configuration or its documentation should change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript, node.js
- Domain
- ci-cd, cloud
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100