CS FundamentalsModerateProduct-company placement · Node.js interview

Two developers run npm install on the same commit a month apart and get different dependency versions, though package.json is unchanged. What prevents this?

  1. A. Deleting node_modules every day
  2. B. Pinning Node.js to the latest version
  3. C. Using only caret ranges
  4. D. Committing the lock file (package-lock.json) and installing from it, e.g. with npm ci

Correct answer: D. Committing the lock file (package-lock.json) and installing from it, e.g. with npm ci

Ranges in package.json resolve to whatever is newest at install time; the lock file records the exact resolved tree. npm ci installs exactly that tree, giving reproducible builds.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic