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 Installing Packages with npm Managing Dependencies in the package.json File

Amandeep Pasricha
Amandeep Pasricha
14,932 Points

When a package.json file is included in your project, does npm install dependencies for that package automatically?

Does that happen automatically when npm installs the package, or do you have to read package.json and do that yourself?

1 Answer

Darryl Mah
Darryl Mah
5,488 Points

Typically the “node_modules” folder containing all the dependencies will not be included in a project file you download. This because they can often carry large amounts of data. The package.json file will include names of the dependence’s but not the actual files. When you run npm install on the project this will trigger npm to look at the dependencies listed in the package.json file and download the the actual codes for these dependencies into the node_modules folder. This prevents you from having to look into that file and installing them all individually.