Web Development

How to Install React JS in Windows 11 – Step by Step Guide

This guide provides a straightforward process for installing React JS on Windows 11. Follow these easy steps to set up your development environment and start building React applications quickly and efficiently.

ReactJS is a popular JavaScript library for building user interfaces, developed and maintained by Facebook. It is widely used for developing single-page applications due to its component-based architecture. In this guide, we will walk through the process of installing and setting up ReactJS on a Windows 11 machine.

1. Prerequisites


Before diving into the installation, ensure you have the following:

  • A Windows 11 machine.
  • Administrator access to the computer.
  • A stable internet connection.
  • Basic knowledge of JavaScript and command line interfaces.

2. Installing Node.js and npm


Installing Node.js and npm

ReactJS relies on Node.js and npm (Node Package Manager) to manage dependencies. Follow these steps to install them:

Download Node.js:

  • Visit the official Node.js website: Node.js
  • Download the LTS (Long Term Support) version, which is recommended for most users.

Install Node.js:

  • Run the downloaded installer.
  • Follow the prompts in the installation wizard.
  • Accept the license agreement.
  • Choose the default installation settings.
  • Click “Install” to begin the installation process.
  • Once installed, click “Finish.”

Verify Installation:

  • Open Command Prompt (Press Win + R”, type cmd”, and press Enter”).
  • Type node -v” and press Enter”. This command will display the installed Node.js version.
  • Type npm -v” and press Enter”. This command will display the installed npm version.

Also Read:- Fast and Secure: Node.js REST API Setup in 5 Minutes

3. Setting Up a React Application


Setting Up a React Application

With Node.js and npm installed, we can now set up a new React application.

Open Command Prompt:

Press “Win + R”, type “cmd”, and press “Enter”.

Navigate to Your Desired Directory:

  • Use the cd” command to change to the directory where you want to create your React application.
  • Example: cd “C:\Users\YourUsername\Projects”

Create a New React Application:

  • Type npx create-react-app my-react-app” and press Enter”.
  • Replace my-react-app with your preferred project name.
  • This command will create a new directory with the specified name and install all the necessary dependencies.

Navigate to Your Project Directory:

  • Type cd “my-react-app” and press Enter”.

Start the Development Server:

  • Type npm start” and press Enter”.
  • This command will start the development server and open your new React application in the default web browser.
  • The application will be running at http://localhost:3000″.

4. Understanding the Project Structure


Your React application directory will have the following structure:

  • node_modules: Contains all the project dependencies.
  • public: Contains the static files like index.html.
  • src: Contains the source code of your React application.
  • package.json: Lists the project dependencies and scripts.
  • README.md: Provides information about the project.

5. Making Changes to Your React Application


To start building your application, you will primarily work within the src directory. Here are some common tasks:

Editing the Main Component:

  • Open src/App.js” in your preferred code editor.
  • Modify the App” component to change the content displayed in your application.

Adding New Components:

  • Create a new file in the src directory, e.g., src/MyComponent.js”.
  • Define a new React component in this file.
  • Import and use this component in src/App.js”.

Styling Your Components:

  • You can add CSS styles in src/App.css”.
  • Import the CSS file in your component file if you create a new one.
  • Example: import ./App.css”;

Also Read:- How to Integrate Redux into Your React Native App?

6. Installing Additional Packages


React has a rich ecosystem of third-party packages. Here’s how to install and use them:

Installing a Package:

  • Open Command Prompt and navigate to your project directory.
  • Type npm install package-name” and press Enter”.
  • Replace package-name” with the name of the package you want to install.

Using the Package:

  • Import the package in your component file.
  • Example: import packageName from ‘package-name’;
  • Use the package as per its documentation.

7. Building the Application for Production


Once your application is ready for deployment, you need to create an optimized build.

Create a Production Build:

  • Open Command Prompt and navigate to your project directory.
  • Type npm run build” and press Enter”.
  • This command will create a build directory with optimized files.

Deploying the Build:

You can deploy the contents of the “build” directory to any static site hosting service like GitHub Pages, Netlify, or Vercel.

8. Troubleshooting Common Issues


Here are some common issues and solutions you might encounter:

npm Command Not Found:

  • Ensure Node.js and npm are installed correctly.
  • Check your system’s PATH environment variable to include the path to Node.js.

Port 3000 Already in Use:

  • Change the default port by setting the environment variable PORT”.
  • Example: set PORT=3001 && npm start”

Application Not Loading:

  • Check the browser console for errors.
  • Ensure all dependencies are installed by running npm install” in the project directory.

Conclusion


By following this guide, you should have successfully installed and set up a ReactJS application on your Windows 11 machine. You have learned how to create a new React project, understand its structure, and start developing your application. Additionally, you have seen how to install additional packages and create a production build for deployment.

ReactJS offers a powerful and flexible way to build modern web applications. With its component-based architecture, you can create reusable components that make development more efficient and maintainable. As you become more familiar with React, you will discover many advanced features and techniques that can further enhance your development experience.

If you’re looking for a reliable partner to bring your web application ideas to life, Shiv Technolabs is here to help. As a premier ReactJS development company in Turkey, we specialize in creating high-quality, scalable, and efficient applications tailored to your business needs. Our React.js expert team is dedicated to delivering exceptional solutions that drive success. Contact us today to start your project with the best in the industry.

background-line

Revolutionize Your Digital Presence with Our Mobile & Web Development Service. Trusted Expertise, Innovation, and Success Guaranteed.

Written by

Dipen Majithiya

I am a proactive chief technology officer (CTO) of Shiv Technolabs. I have 10+ years of experience in eCommerce, mobile apps, and web development in the tech industry. I am Known for my strategic insight and have mastered core technical domains. I have empowered numerous business owners with bespoke solutions, fearlessly taking calculated risks and harnessing the latest technological advancements.