Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm update changing package.json #3044

Closed
mattpen opened this issue Apr 7, 2021 · 5 comments
Closed

[BUG] npm update changing package.json #3044

mattpen opened this issue Apr 7, 2021 · 5 comments
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release

Comments

@mattpen
Copy link

mattpen commented Apr 7, 2021

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
@mattpen mattpen added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Apr 7, 2021
@ZwapKillrath
Copy link

Related to #708?

@darcyclarke
Copy link
Contributor

@mattpen can't seem to reproduce; Can you try updating to latest (npm i -g npm should be v7.9.0)

@darcyclarke darcyclarke removed the Needs Triage needs review for next steps label Apr 9, 2021
@mattpen
Copy link
Author

mattpen commented Apr 9, 2021

@darcyclarke - I just upgraded and I still get the same results (npm update inserts trailing newline into package.json) with v7.9.0.

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

up to date, audited 1 package in 158ms

found 0 vulnerabilities
$ cat package.json 
{}
$ npm -v
7.9.0
$ 

@mattpen
Copy link
Author

mattpen commented Sep 9, 2021

Using node 14 or 16 this problem does not occur.

@ruyadorno
Copy link
Contributor

#4223 cleans up the usage of save config in npm update

Closing this issue since the original problem should be fixed in npm@8.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

4 participants