Install Node.js: Go to the Node home page. Click the big green button that has a version number followed by “LTS" -- Long-Term Support.
Web Server: knows where the file is on the computer and serves it to the browser
npm: the ubiquitous package manager for Node packages, installed when you install Node
** npm install -g [pkg_name]: install the package globally
*** JavaScript utilities (like nodemon) will generally be installed globally, whereas packages that are specific to your web app or project will not.
You can find out what version of Node is installed on your computer by typing
node --version
.localhost: as the name implies, refers to the computer you’re on. Alias for 127.0.0.1.
Node
- Run Node.js file:
- In terminal:
node [filename]
- In browser: http://localhost:3000
- In terminal:
- Event-Driven Programming: understand what events are available to you and how to respond to them
- Making HTTP request:
http.createServer
method takes a function as an argument; that function will be invoked every time an HTTP request is made. - Routing: User navigates to another page
Express
A “minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.”
- The server-side part of a web app
- What Express does is very simple: it accepts HTTP requests from a client and returns an HTTP response.
- Express offers leading performance for high-traffic websites.
Server-Side vs. Client-Side Applications
- Server-Side: HTML pages are rendered on the server. Then get sent to the client.
- Client-Side: HTML pages are rendered dynamically on the client-side. Client side only receives an initial raw HTML files from server, then uses JS file at client to render everything (without server's assistance).
Server-side applications are often called server-side rendered (SSR), and client-side applications are usually called single-page applications (SPAs). Client-side applications are fully realized in frameworks such as React, Angular, and Vue.
In general, if the server sends a small number of HTML files (generally one to three), and the user experiences a rich, multiview experience based on dynamic DOM manipulation, we consider that client-side rendering.