A Description of package.json File using Node.js, Including How to Install Packages Using It
Posted on July 15, 2015 in Node.js by Matt Jennings

Rules for Creating and Installed a package.json File

  • The package.json file will live at specific directory I’m working in for a Node.js app.
  • The "name" property value needs to be very short.
  • The "scripts" property value is used as a short-cut when using Mac terminal to start up my node project.For example if I have the nodemon module installed globally, in Mac Terminal I can navigation to my specific Node.js app directory and type in the command below where will execute the nodemon package on my server.js file:
  • The "dependencies" property value includes a single object value that includes property value pairs listing the npm module to be installed and the specific version of the said npm module.In the example package.json file below, the npm modules to be installed are Express, EJS, and The 4.13.x value of the "express" property, means that the Express module will only update up to the highest version of 4.13 (like 4.13.9) but NOT up to 4.14 (like 4.14.1).
  • To install the npm modules listed in the package.json file, in Mac terminal while in said Node.js app directory, type this code and press enter:
    npm install
  • If the Express, EJS, and npm modules are successfully installed a node_modules directory will be created in said Node.js app directory with said modules inside.
  • If said npm modules do NOT install successfully a node_modules directory will NOT be created in said Node.js app directory and you should see error messages in Terminal.

Example package.json File

  "name": "",
  "description": "example of adding sockets to express using node",
  "version": "0.0.1",
  "scripts": {
    "start": "node server.js"
  "dependencies": {
    "express": "4.13.x",
    "ejs": "2.3.x",
    "": "1.3.x"

Leave a Reply

To Top ↑