Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript npm Basics (retiring) Updating and Uninstalling Packages with npm Uninstalling Packages with npm

Kevin Ohlsson
Kevin Ohlsson
4,559 Points

npm uninstall removes dependency in .json

Hello

When i use "npm uninstall express" without flags it also removes the dependency in the projects npm init (.json) file.

why is this the case? shouldnt the command "npm uninstall express --save" do this, but not the normal command?

https://i.imgur.com/NAbdVRE.png

https://i.imgur.com/Fo4swER.png

Kevin Ohlsson
Kevin Ohlsson
4,559 Points

Thank you AI for clarify I will check docs in future too

1 Answer

I know that, at some point --save-prod or -P became the default behavior for "npm install". It even states it in the help "npm help install".

It seems that uninstall is also behaving as if --save or -S was the default (tested with NPM 5.6.0 and 6.1.0). The help for uninstall, "npm help uninstall", and the docs both still say that you need it.

You can use the --no-save flag to keep it from removing the dependency in package.json.