pacote icon indicating copy to clipboard operation
pacote copied to clipboard

[BUG] config field gets overwritten in package.json

Open alexpineda opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

When extracting to a folder where the same (but older version) package exists, it does not respect the npm package constraint that config should not be touched by the package manager.

Expected Behavior

When extracting to a folder where the same (but older version) package exists, it should respect the npm package constraint that config should not be touched by the package manager.

Steps To Reproduce

  1. In windows
  2. Have an existing package of your choice, change it's package.json version to be lesser than the published version, if there is no config field in package.json add one eg "config": "dontTouchMe":true
  3. Run packote.extract in the same directory
  4. "config" will be wiped out

Environment

  • npm: 7.20.3
  • Node: 16.6.2
  • OS: Windows 10
  • platform: MSI Laptop

alexpineda avatar Mar 11 '22 04:03 alexpineda

I'm not sure if this behavior is desirable on your end for this package but I did want to make note of it as it could arguably violate package.json constraints specified in the npm documentation. For my personal use I have leveraged deepmerge to merge the old config onto the incoming package config.

alexpineda avatar Mar 11 '22 04:03 alexpineda

The config contained in the package.json is considered part of the version you are installing. It's intentionally coupled to that version's package.json. This is by design.

wraithgar avatar Oct 19 '22 14:10 wraithgar