Skip to content

[BUG] npm update changing package.json #3044

@mattpen

Description

@mattpen

Current Behavior:

npm update will make changes to package.json, even if --save=false or --no-save is present. This includes adding a newline to the end of package.json even if no other changes were present.

Expected Behavior:

If save is set to false, npm update should not modify package.json

Steps To Reproduce:

I see this same behavior with npm config set save false, npm update --no-save, and npm update --save=false.

$ echo -n {} | cat > package.json
$ cat package.json               
{}%                                                                                                  
$ npm config get save            
false
$ npm update                     

up to date, audited 1 package in 151ms

found 0 vulnerabilities
$ cat package.json               
{}
$

Environment:

  • OS: MacOS 11.2.3 (M1)
  • Node: 15.9.0
  • npm: 7.5.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions