-
go to the Node.js website Download and install the LTS version (recommended for most users).
-
Verify with
node -vandnpm -v -
Make a project directory
-
npm init -y -
To create a Node.js server you need a package called
express. install it withnpm install expressornpm i express -
create a
server.jsfile. usetouchor whatever. -
Stuff needs to be kept secret so, create a .env file and also
npm i dotenvornpm install dotenvthe most common use for this is secure keys and also port number for the server by using the PORT variable . -
app.use() app.post() app.get() are all express methods
-
in order to use express in your
server.jsfile you need to require it and use it by
const express = require('express');
const app = express();Keep in mind this is the ES5/ES6 way which is still accepted even though ES7+ uses import.