Package Managers

package.json, bower.json

Package managers, such as NPM and Bower, keep track of what modules you are using through JSON files. In general, these files contain information about the project overall, as well as which modules have been downloaded for the project, specifically. If you choose to move a project from one machine to another e.g. into GitHub (or submitting to the site), these .json files minimize the need for copying all of the dependent modules that we download from the package management sites, keeping the overall size of the project that we pass much smaller.

We have dealt with three packages that we include in a lot of our files so far that aren’t pre-installed with node: express, ejs, and body-parser. Let’s use NPM’s package.json file!

Create an empty folder called TestProject
  • navigate to that folder using your terminal/command-prompt/bash.
  • in terminal/command-prompt/bash type npm init -y
    • this command basically says: we are using this folder for an npm based project, (npm init), the (-y) says fill the package.json with the base information.
  • If you open this file, the contents should look something like this:

``` { "name": "TestProject", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo "Error: no test specified" && exit 1" }, "keywords": [], "author": ""...