From d0cdcb61fe3a237be7d905cecc9ff1b95dbfdfa3 Mon Sep 17 00:00:00 2001
From: Rebecca Turner npm install A
will install:
A@0.1.0
`-- B@0.0.1
`-- C@0.0.1
-
However, if B@0.0.2 is published, then a fresh npm install A
will
+
However, if B@0.0.2 is published, then a fresh npm install A
will
install:
A@0.1.0
`-- B@0.0.2
@@ -61,7 +61,7 @@ install:
assuming the new version did not modify B's dependencies. Of course, the new version of B could include a new version of C and any number of new dependencies. If such changes are undesirable, the author of A -could specify a dependency on B@0.0.1. However, if A's author and B's +could specify a dependency on B@0.0.1. However, if A's author and B's author are not the same person, there's no way for A's author to say that he or she does not want to pull in newly published versions of C when B hasn't changed at all.
@@ -125,6 +125,19 @@ package source to get the exact same dependency tree that you were developing on. Additionally, the diffs from these changes are human-readable and will inform you of any changes npm has made to yournode_modules
, so you can notice
if any transitive dependencies were updated, hoisted, etc.
+Occasionally, two separate npm install will create package locks that cause
+merge conflicts in source control systems. As of `npm@5.7.0, these conflicts
+can be resolved by manually fixing any
package.jsonconflicts, and then
+running
npm install [--package-lock-only]again. npm will automatically
+resolve any conflicts for you and write a merged package lock that includes all
+the dependencies from both branches in a reasonable tree. If
--package-lock-onlyis provided, it will do this without also modifying your
+local
node_modules/`.
To make this process seamless on git, consider installing
+npm-merge-driver
, which will teach git how
+to do this itself without any user interaction. In short: $ npx
+npm-merge-driver install -g
will let you do this, and even works with
+pre-`npm@5.7.0versions of npm 5, albeit a bit more noisily. Note that if
package.jsonitself conflicts, you will have to resolve that by hand and run
npm install` manually, even with the merge driver.