reading-notes

Node, Express, and APIs

Source: An Introduction to Node.js

What is Node.js

Installing Node.js

Package Management w/ NPM

To install a package globally

  npm install -g jshint

To install a package locally

  npm init -y
  npm install lodash --save

This process does 2 things:

This specifies which packages are neded in a file

Using Node.js

Run JavaScript on the Server

The biggest use case for Node.js

Example

hello-world-server.js

const http = require('http');

http.createServer((request, response) => {
  response.writeHead(200);
  response.end('Hello, World!');
}).listen(3000);

console.log('Server running on http://localhost:3000');
node hello-world-server.js

Browser: http://localhost:3000

Note: Use nodemon to autoreload server changes

Disadvantages

Advantages

Use Node.js for…

Other Uses