Nodejs and PostgreSQL, Practical Introduction (Connection and Basic Queries with Javascript)

Abraham Murillo
7 min readFeb 20, 2021

In this tutorial, I will show you how to create a Node Server and the basic queries with PostgreSQL.

Prerequisites

  • NodeJS installed
  • PostgreSQL installed
  • Basic JavaScript
  • Terminal
  • Text Editor
  • Postman

First thing first

To start it is necessary to first create a new folder called as you want, for this tutorial I am going to call it node-postgres, and then inside the folder open a new terminal with the folder path and initialize our project, for this, just write the following command in the terminal.

npm init -t

This will create a file called package.json with default values, for our project which contains all the project references such as the author, repository, version, and most important of all the project dependencies.

example of package.json

Before starting to write our code, we are going to install the dependencies, for this tutorial only…

--

--