What is the difference between npm install and npm ci?

BeginnerConceptNode.js builds (npm, package.json)
Answer

Short answer

npm install installs packages based on package.json and may update package-lock.json. npm ci ("clean install") deletes node_modules and installs exactly what's in the lockfile — and fails if the lockfile and package.json don't match. Use npm install on your laptop to add/update packages; use npm ci in CI and Docker builds.

Comparison

npm install npm ci
Source of truth package.json (+ lockfile) lockfile only
Changes the lockfile? Can Never
Existing node_modules Updated in place Deleted first
Out-of-sync lockfile Silently fixes it Fails the build
Repeatable? Not guaranteed Yes

Example

npm install axios        # developer adds a package → package.json + lockfile updated, committed
npm ci                   # pipeline installs the exact same tree
npm ci --omit=dev        # production image: skip devDependencies

What to say in the interview

"npm ci gives deterministic installs from package-lock.json and fails if it's out of sync, so it's what we use in pipelines and Dockerfiles. npm install is for developers changing dependencies."

All Build Tools (Java, Node.js, Python, .NET) questions Roadmap: Node.js apps: npm & package.json

More on Node.js builds (npm, package.json)