Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Kevin Ohlsson
Kevin Ohlsson
4,547 Points

npm uninstall removes dependency in .json


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?



Kevin Ohlsson
Kevin Ohlsson
4,547 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.