Node

Overview

Node.js—also known as Node—which was created in 2009 as a simple and efficient runtime for server-side applications written in JavaScript. Node.js is based on the JavaScript engine used in the Chrome browser and provides an API for executing JavaScript code outside of the browser environment. The Node.js installer includes the Node Package Manager (npm), which is used to manage the packages in a project.

npm

  • Allows you to install external node packages from the command line
    • These packages can be a set of utility functions, libraries or whole frameworks
    • They are the dependencies of your application
    • You can either install these packages to your global node package folder or to your local project folder

package.json

  • Enables you to share your project with other developers without sharing all the node packages
    • Has all the references of node packages used in your project
    • These packages are called dependencies
  • npm install takes all the dependencies listed in the package.json file and installs them in the node_modules folder

Cheat Sheet

# Initialize a default package.json file and create a node_modules folder
npm init -y
# Install a local package
npm install <package>