Open sersorrel opened 12 months ago
Note: this issue is also present in npm 10.1.0.
It does have some functionality but it's a best effort. The resolution is done by https://github.com/npm/parse-conflict-json.
Since it has never done diff3 I'm hesitant to call this a bug. Adding diff3 would potentially mean adding that capability to the underlying https://www.npmjs.com/package/just-diff module, and it definitely would mean adding diff3 support to parse-conflict-json.
We'd welcome PRs that added this, but it'd be a new feature. This feature is not something the npm team would be actively working on though.
parse-conflict-json looks like it's meant to have support for diff3 diffs, though – the tests include a file with diff3 markers, and it includes a regex to match the |||||||
marker you find in diff3 diffs but not regular diffs.
Here's a gist of the package.json and package-lock.json I experienced this with.
Ah ok, I just searched for 'diff3' not the markers themselves. It looks like diff3 is supported but your particular conflict isn't.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
When package-lock.json is conflicted, I believe npm has some functionality to automatically resolve the conflicts when you
npm install
. However, this doesn't work consistently when git is configured to use diff3 conflict markers – here I get a "must provide string spec" error, much like #2117:That log contains the following stack trace:
Expected Behavior
I'd hoped that npm would be able to understand both regular conflict markers and the (more useful) diff3 markers.
The error can, however, be worked around via
git checkout --conflict=merge package-lock.json
.Steps To Reproduce
git checkout --conflict=diff3 package-lock.json
to make sure it uses diff3 markersnpm i
Environment