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 will live at specific directory I’m working in for a Node.js app.
"name" property value needs to be very short.
"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
"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 Socket.io. 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:
- If the Express, EJS, and Socket.io 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.
"description": "example of adding sockets to express using node",
"start": "node server.js"
Leave a Reply