How do semver ranges in `package.json` (`^`, `~`) behave and why do lockfiles matter?
IntermediateConceptBuild Tools and Artifact Repositories
Answer
^1.4.2 allows any 1.x.x at or above 1.4.2, ~1.4.2 allows 1.4.x patches only. Without a lockfile, two builds on different days can resolve different transitive versions. The committed package-lock.json pins every version and integrity hash (SHA-512), making installs reproducible and giving a defence against tampered registry packages.
More on Build Tools and Artifact Repositories
What is Maven and what is its build lifecycle?BeginnerWhat is the difference between `mvn package`, `install` and `deploy`?BeginnerHow do Maven dependency scopes and transitive dependencies work?IntermediateWhat is `settings.xml` in Maven and how do CI builds use it?IntermediateWhat is the Maven Wrapper and why use it?BeginnerHow do you cache dependencies and speed up Maven builds in CI?Intermediate