NPM

NPM - Node Package Manager

MOAR APIs

Reusable code

Open Source Software

IoT Integrations

NPM - Why?

NPM - Why?

Makes code portable

NPM - Why?

Makes code portable

Manages dependancies (libraries you need to run your app)

NPM - Why?

Makes code portable

Manages dependancies (libraries you need to run your app)

Keeps project metadata consistent

NPM - Why?

Makes code portable

Manages dependancies (libraries you need to run your app)

Keeps project metadata consistent

Access thousands of packages, so you don't have to reinvent the wheel

NPM - Why?

Makes code portable

Manages dependancies (libraries you need to run your app)

Keeps project metadata consistent

Access thousands of packages, so you don't have to reinvent the wheel

Consistent interface allows easy deployment

NPM - Why?

Makes code portable

Manages dependancies (libraries you need to run your app)

Keeps project metadata consistent

Access thousands of packages, so you don't have to reinvent the wheel

Consistent interface allows easy deployment

Part of a 12-factor app, and a balanced breakfast

NPM - package.json

$ npm init

Walks you through creating a package.json file

NPM - package.json

{
  "name": "node_example",
  "version": "1.0.0",
  "description": "This is an example project",
  "main": "app.js",
  "scripts": {
       "start" : "node app.js"
   },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "request": "^2.67.0"
  }
}

NPM - package.json

{
  "scripts": {
       "start" : "node app.js"
   }
}
$ npm start

To run your node program:

Set by this field in package.json

Now every node program is started the same way, even if you name your files differently!

NPM - package.json

"dependencies": {
    "request": "^2.67.0"
}
$ npm install

This command:

Installs each package in this field in package.json

NPM - Package Manager

$ npm install module-name --save

This command:

Installs new modules, then saves them in package.json

Using Modules - require()

Using Modules - require()