top of page
Search

Node Base Project

  • damiankozlowski
  • Jan 4, 2021
  • 2 min read

Updated: Nov 11, 2021

This short blog post outlines steps required to setup a basic Node project with Express framework which I will use as a base for future articles. At the completion of this guide, you should be able to query the Node server using Postman on http://<YourIP>:3000/test and receive the following JSON response:


ree

The purpose of this simple Node project is solely to be used as a scaffolding for my blog posts, therefore, it does not include encryption, authentication, and global error handling.


Before you start, you will need:

  • A Linux server (I'm using Amazon Linux v2)

  • Firewall TCP 3000 and 22 ports open from your PC to the server (unless you are instilling Node on a local PC)

  • Internet access

  • 15 minutes to spare

Install Node.js

In this step you will install the latest version of Node.js on your Linux Server using NVM.

  • Login to Node server's shell using putty or SSH client of your choice.

  • Install NVM ( https://github.com/nvm-sh/nvm#installing-and-updating).

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
  • Activate NVM.

. ~/.nvm/nvm.sh
  • Install Node version 16.13.0 ( Releases - https://nodejs.org/en/about/releases/)

nvm install 16.13.0

Deploy Base Project

In this step you will download the base project from GitHub and start the application.

  • Download project from the Github (if you are familiar with GitHub you can clone it instead "git clone https://github.com/Damian-600/blog-project.git <Folder Name>").

wget https://github.com/Damian-600/blog-project/archive/master.tar.gz
  • Extract project files and rename folder

tar -xf master.tar.gz
mv blog-project-master node-project
  • Structure of your folder should look like this

ree

  • Install project dependencies

npm install

NPM will create new folder node_modules with all dependent packages.

  • Audit and update modules

npm audit fix

NPM will check for known vulnerabilities in dependencies included in the package.json file. The fix switch will attempt to remediate found vulnerabilities.

  • Start Node project

node server.js

You should see the following output on the screen

ree

Test Node Project

In this section you will query the Node server using Postman.

  • Open Postman, set the query method to GET and enter the following URL http://<YourIP>:3000/test, replace <yourIP> with the public IP address of the Node server.

You can download Postman from here.

ree

Comments


Post: Blog2_Post

Subscribe Form

Thanks for submitting!

COPYRIGHT © 2021 · ALL RIGHTS RESERVED

bottom of page