Skip to main content

Python type() Function

When learning Python, you will work with different types of data, such as numbers, text, decimal values, and Boolean values. Python provides several built-in functions to help you work with these data types. One of the most useful functions is the type() function . The type() function tells you the data type of a value or variable. It helps you understand what kind of data Python is working with and can make debugging your programs easier. For example, consider these variables: age = 20 price = 99.50 name = "Rahul" is_student = True Although all four variables store data, their data types are different. Python allows us to check these types using type() . Let's understand how it works with simple examples. 1. What Is the type() Function in Python? The type() function is a built-in Python function that returns information about the type of an object. In beginner-level programming, you can use it to check whether a value is an integer, a floating-point number, a string,...

Setting Up Your First PERN Stack Development Environment

Introduction

In the previous article, we learned about the basics of the PERN stack and understood how PostgreSQL, Express.js, React.js, and Node.js work together to build modern web applications.

Now it is time to take the next step — setting up your complete PERN stack development environment. Before building any project, developers need to install the required tools and configure their system properly.

In this article, we will learn:

  • Required software for PERN stack development

  • Installing Node.js

  • Installing PostgreSQL

  • Installing VS Code

  • Setting up React

  • Creating backend and frontend folders

  • Running your first PERN project


Requirements for PERN Stack Development

Before starting, make sure your system has:

  • Internet connection

  • Minimum 4GB RAM

  • Windows, Linux, or macOS

  • Basic understanding of JavaScript


Step 1: Install Node.js

What is Node.js?

Node.js allows JavaScript to run outside the browser. It is required for both backend development and managing packages.

It also installs npm (Node Package Manager) automatically.


How to Install Node.js

For Windows

  1. Visit the official website:

  2. Download the LTS Version

  3. Run the installer

  4. Keep clicking Next

  5. Finish installation


Verify Installation

Open Command Prompt and type:

node -v

Example output:

v22.0.0

Now check npm:

npm -v

If both commands work, Node.js is installed successfully.


Step 2: Install Visual Studio Code

What is VS Code?

Visual Studio Code is one of the most popular code editors for web development.


Install VS Code

  1. Visit:

  2. Download for your operating system

  3. Install normally


Recommended Extensions

Install these extensions from VS Code marketplace:

  • ES7+ React Snippets

  • Prettier

  • PostgreSQL

  • Thunder Client

  • Material Icon Theme

These extensions improve productivity and make development easier.


Step 3: Install PostgreSQL

What is PostgreSQL?

PostgreSQL is the database used in the PERN stack.

It stores application data such as:

  • User accounts

  • Test scores

  • Products

  • Orders

  • Messages


Install PostgreSQL

  1. Visit:

  2. Download PostgreSQL

  3. Run installer

  4. During installation:

    • Set password carefully

    • Remember the port number (default: 5432)

  5. Install pgAdmin along with PostgreSQL


Verify PostgreSQL Installation

Open pgAdmin and connect using your password.

Create a test database to ensure everything works correctly.


Step 4: Create Project Folder

Create a folder for your PERN project.

Example:

PERN_Project

Inside it create two folders:

client
server

Folder Structure

PERN_Project
│
├── client
└── server
  • client → React frontend

  • server → Express backend


Step 5: Setup React Frontend

Now open terminal inside the project folder.

Run:

npx create-react-app client

This command creates a React application.


Start React Application

Move inside client folder:

cd client

Run the project:

npm start

Your browser will open:

http://localhost:3000

Congratulations! Your React frontend is working.


Step 6: Setup Express Backend

Now open another terminal.

Move to server folder:

cd server

Initialize Node.js project:

npm init -y

Install Required Packages

npm install express cors pg nodemon

Package Explanation

PackagePurpose
expressBackend framework
corsConnect frontend and backend
pgPostgreSQL driver
nodemonAuto restart server

Step 7: Create Basic Express Server

Inside server folder create:

index.js

Add this code:

const express = require('express');
const cors = require('cors');

const app = express();

app.use(cors());
app.use(express.json());

app.get('/', (req, res) => {
    res.send('PERN Backend Running');
});

app.listen(5000, () => {
    console.log('Server started on port 5000');
});

Run Backend Server

Run command:

node index.js

Or using nodemon:

npx nodemon index.js

Output:

Server started on port 5000

Step 8: Test Backend in Browser

Open:

http://localhost:5000

You should see:

PERN Backend Running

This means your backend is working successfully.


Understanding the Full Workflow

Now your PERN setup is ready.

Current Architecture

React Frontend  →  Express Backend  →  PostgreSQL Database
  • React handles UI

  • Express handles APIs

  • PostgreSQL stores data


Common Beginner Mistakes

1. Node Command Not Working

Solution:

  • Restart system

  • Reinstall Node.js


2. Port Already in Use

Solution:

  • Change port number

  • Close running applications


3. PostgreSQL Password Forgotten

Solution:

  • Reinstall PostgreSQL or reset password


4. React App Not Starting

Solution:
Run:

npm install

Then:

npm start

Benefits of Proper Environment Setup

A properly configured environment helps you:

  • Develop faster

  • Avoid errors

  • Manage projects efficiently

  • Deploy applications smoothly


Conclusion

You have successfully set up your first PERN stack development environment. Now your system is ready for building full-stack web applications.

In the next article, we will learn how to:

  • Connect PostgreSQL with Node.js

  • Create databases and tables

  • Perform CRUD operations

  • Build your first API

This is where real backend development begins.

Comments

Popular posts from this blog

Understanding Comments in Java: A Beginner’s Guide

When learning Java programming, one of the first concepts you’ll come across is comments . Comments may not affect how a program runs, but they play a crucial role in making code more understandable, readable, and maintainable. Let’s dive deeper into what comments are, why they’re important, and the different types of comments in Java. What are Comments in Java? A comment in Java is a piece of text written within a program that is ignored by the compiler . In other words, comments are notes for humans, not instructions for machines. They help developers explain the purpose of code, describe logic, or temporarily disable certain lines of code without deleting them. Why are Comments Important? 📌 Readability – Comments make code easier to understand for you and others. 📌 Maintenance – When you revisit your code after months, comments remind you what you were doing. 📌 Collaboration – In team projects, comments explain code to fellow developers. 📌 Debugging – You c...

Java Program to Check Voting Eligibility

In this program, we’ll take the user’s age as input and check whether the person is eligible to vote or not. In India, the minimum age required to vote is 18 years . 💻 Program Code // Java Program to Check Voting Eligibility import java.util.Scanner; public class VotingEligibility { public static void main(String[] args) { // Create Scanner object to take input from user Scanner sc = new Scanner(System.in); // Ask user to enter age System.out.print("Enter your age: "); int age = sc.nextInt(); // Check eligibility if (age >= 18) { System.out.println("You are eligible to vote."); } else { System.out.println("You are not eligible to vote yet."); System.out.println("You can vote after " + (18 - age) + " year(s)."); } sc.close(); // Close the scanner } } 🧠 Explanation import java.util.Scanner; → Imp...

Java Program to Calculate Total Marks and Average of Five Subjects

💡 Program Explanation In this program: The user will input marks of five subjects . The program will calculate the total marks and average . It will then display both results clearly. 🧑‍💻 Java Code: // Java Program to Calculate Total Marks and Average of Five Subjects import java.util.Scanner; // Importing Scanner class for user input public class TotalAndAverage { public static void main(String[] args) { // Creating Scanner object to take input from user Scanner sc = new Scanner(System.in); // Declaring variables for five subjects double subject1, subject2, subject3, subject4, subject5; // Taking marks input for each subject System.out.print("Enter marks of Subject 1: "); subject1 = sc.nextDouble(); System.out.print("Enter marks of Subject 2: "); subject2 = sc.nextDouble(); System.out.print("Enter marks of Subject 3: "); subject3 = sc.nextDo...