- Set up:
$ mkdir node-http-server
$ cd node-http-server
$ npm init --yes
$ npm i dotenv
$ touch server.js secret.js
// 1: npm i dotenv | |
// 2: require packages | |
const http = require('http'); | |
require('dotenv').config(); | |
const PORT = process.env.PORT || 3000; // You can set default port to 3000 if port is not defined | |
// 3: create server (and use packages): |
// Write a Node.JS program that executes a connection to server and | |
// returns success message like "Success, I'm listening from the port: 3000" | |
// hint: very similar what we just did on the class | |
// ...your code here |
$ nvm install node
nvm is a terminal command that allows you to install and change between different versions of Node.js. Usually, your system can have only one version of Node.js installed at one time. With nvm, you can switch to a newer version, try some new features, and then back to an older version for your more serious projects.
$ mkdir ~/.nvm
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
Install the latest Node.js
Node.js is becoming a requirement for today's Web development toolkit thanks to popular projects like Facebook's React. We'll discuss it in more detail during the course.
node
and was installed:$ node --version # or node -v
# v12.6.0 (current, but in the time you check might be different)