aws-amplify / aws-amplify/amplify-hosting

Why cache node_modules when prebuild command is "npm ci"?

Open
#2,831 1 comment 0 reactions 0 assignees View on GitHub
frontend-builds usability
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.