pacote
pacote copied to clipboard
[BUG] config field gets overwritten in package.json
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
- In windows
- 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
- Run
packote.extract
in the same directory - "config" will be wiped out
Environment
- npm: 7.20.3
- Node: 16.6.2
- OS: Windows 10
- platform: MSI Laptop
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.
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.