Creating a Simple Server that sends the message, "Hello World" , using Nodejs
Introduction.
In our first task on our "Journey to transition into Tech through Frontend and Backend Web development program", we had the opportunity to set up our development environment by installing the necessary code editors such as VS Code, Ubuntu (a Linux package), and Node.js. I also had the opportunity to install Git and also create a GitHub repository account.
Task: In this article, I will be taking you on a journey on how to set up a simple server that sends the message "Hello World!" using Node.js. I will therefore use Git to push the codes to GitHub by linking my GitHub account.
Prior Knowledge: Express.js (a minimalist and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. Link: https://expressjs.com/)
Procedures
1. The git bash terminal was opened from my desktop using the right-click option on the mouse. As the pop-up window emerged, a folder was created using the command; make a directory (mkdir)
command: mkdir (folder_name).
Another option is to create a folder from the Windows pop-up window by clicking the right-click option on the mouse.
2. Still within the git bash environment, the "call directory" command was issued;
command: cd (folder_name).
This allows you to "work" within the folder (root directory).
3. This next command was used to initial VS code as it was the code editor for this app.
command: code .
Another option is to open the folder created (root directory) manually in VS code by first initializing the app from the start menu on the PC.
4. As the VS code was initialized, the terminal was opened and the git bash terminal initialized from the available options.
5. Since Node.js was already installed on the PC, it was initialized using the command;
command: npm init
6. The command opens up a set of instructions that had options to type in "keywords", "author", "description", "app version", etc. This also creates a package.json file within the root directory on the VS code editor as well as the file (index.js).
7. Using the code package manager (npm) of Node.js you will use the following commands;
command: npm i (wait for it to finish loading)
npm install express (this installs the dependency list, Express.js in the root directory by
adding a file to the package-lock.json file and also creates the node_modules).
Honorable Mentions.
Google: This search engine comes in handy. A tool that can be used to find great resources, codes, files, and every information needed by a web developer.
Thanks for your time.
Daniel Kwasi Kpeglo.
Physicist| SQL| Python| HTML| CSS| JavaScript| Looker| LookML| BigQuery| Power BI| Tableau| GCCP
GitHub Link: https://github.com/Daniel-Kwasi-Kpeglo
Comments