2

Using yarn 2's new plug n play (pnp) creates a long .pnp.js file. I get a bunch of merge conflicts while pulling, and these are not autofixed (unlike yarn.lock).

How are these conflicts solved? I'd rather not go them through manually as it's not clear what change to accept.

Example conflict

        ["virtual:844e49f9c8ad85b5809b347eb507fe8bfdc2d527102f53e0b4f78076a2ad5ea2556763170701137a2cafdc51d5a36d82e448010e65742a300748e0bc70028101#npm:11.2.7", {
          "packageLocation": "./.yarn/$$virtual/@testing-library-react-virtual-2e67fd5293/0/cache/@testing-library-react-npm-11.2.7-3a0469c756-389c9f3e83.zip/node_modules/@testing-library/react/",
          "packageDependencies": [
            ["@testing-library/react", "virtual:844e49f9c8ad85b5809b347eb507fe8bfdc2d527102f53e0b4f78076a2ad5ea2556763170701137a2cafdc51d5a36d82e448010e65742a300748e0bc70028101#npm:11.2.7"],
            ["@babel/runtime", "npm:7.13.10"],
<<<<<<< HEAD
            ["@testing-library/dom", "npm:7.30.4"],
            ["@types/react", "npm:17.0.3"],
            ["@types/react-dom", "npm:17.0.3"],
=======
            ["@testing-library/dom", "npm:7.31.0"],
            ["@types/react", "npm:17.0.8"],
            ["@types/react-dom", "npm:17.0.5"],
>>>>>>> d2bb5d9e537f9647e9757656de230e56282e0b15
            ["react", "npm:17.0.2"],

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Gabriel Petersson
  • 8,434
  • 4
  • 32
  • 41

1 Answers1

0

I would assume you can delete this file containing merge conflicts. Next, you run yarn install which will generate this file again.

Or just run yarn install which will overwrite the the .pnp.cjs file and fix the merge conflicts (if any) in the yarn.lock file for you.

From the docs:

The generated .pnp.cjs file can be committed to your repository 
as part of the Zero-Installs effort, removing the need to run yarn install in the first place.

As you can read, this file can - not must - be committed. However, if you commit it, you can use all your dependencies immediately after cloning the repo, switching branches, ... without need to run yarn install every time.

Note that the same does not count for yarn.lock file which you should never delete.

ThdK
  • 9,916
  • 23
  • 74
  • 101
  • So `pnp.js` always becomes the same file after a `yarn install`, meaning it can safely be removed and generated back without a line changing? – Gabriel Petersson Sep 15 '22 at 22:01