Create A Single Page Website Using Node - Js and Express - Js - by Ankit Maheshwari - JavaScript in Plain English - Medium
Create A Single Page Website Using Node - Js and Express - Js - by Ankit Maheshwari - JavaScript in Plain English - Medium
To build a Website in Node.js we will use Express.js framework. Any other framework
can also be used but Express.js is very popular when using Node.
To check whether the Node.js is already installed on your computer, open your terminal
or CMD and run node -v command. If you see your Node.js version means it's installed.
We will not use express-generator in this article, instead we will create everything by
ourself to avoid extra files generated from generator and to understand in depth.
{
"name": "node-ex-website",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.17.1"
}
}
npm install
After dependency installation this will create "node_modules" folder at the root of the
"node-ex-website" folder.
Template (index.html)
Replace your → node-ex-website/express/index.html file with code below, or you may
use your own template.
You may also add all your static files inside express folder like…
→ node-ex-website/express/css and node-ex-website/express/js
node-ex-website/express/index.html file
Run Project
We have just created a Node-Express Project 😍 Let’s start a server.
To start a server run this command:
npm start
To test this API — Open your web browser and enter this URL → localhost:3000
If you wouldn’t mind giving it some claps 👏 👏 since it helped, I’d greatly
appreciate it :) Help others find the article, so it can help them!
Always be clapping…
Learn More