Question

how do I install React?

I have only just started using Digital Ocean. I have installed npm. I want to install React.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
July 5, 2023
Accepted Answer

Hey @tinnis,

There are two ways to go about this, the first one would be using the Droplet you have and the second one going for the DigitalOcean App platform.

In case you choose the DigitalOcean App platform, you can follow this tutorial:

https://www.digitalocean.com/community/tutorials/how-to-deploy-a-react-application-to-digitalocean-app-platform

In case you choose the Droplet, you can follow these steps:

To install React in your Digital Ocean droplet, follow these steps. This assumes you’re using Ubuntu and that you already have npm (Node.js Package Manager) installed.

  1. Log into your server:

Use SSH to log into your Digital Ocean droplet:

ssh root@your_droplet_ip

Replace “your_droplet_ip” with the IP address of your droplet.

  1. Update your Ubuntu system:

Before installing any new software, it’s generally a good idea to make sure your Ubuntu system is up to date. You can do this with the following commands:

sudo apt-get update sudo apt-get upgrade
  1. Install create-react-app:

Create React App is a comfortable environment for learning React, and is the best way to start building a new single-page application in React. It sets up your development environment so that you can use the latest JavaScript features, provides a nice developer experience, and optimizes your app for production.

You can install it globally using the following command:

npm install -g create-react-app
  1. Create a new React application:

Once you have create-react-app installed, you can use it to create a new React application with the following command:

create-react-app my-app

Replace “my-app” with the name of your application.

  1. Start the application:

To start your React application, navigate into the application directory and start the server:

cd my-app npm start

Your React application should now be running. You can access it by opening a web browser and navigating to http://your_droplet_ip:3000. Replace “your_droplet_ip” with the IP address of your droplet.

  1. Set up a production build (optional):

The above steps will run your application in development mode. If you’re ready to create a production build, use the following command in your application directory:

npm run build

This will create a build directory in your application directory with a production-ready version of your application.

Please note that you’ll want to set up a proper web server like Nginx to serve your production React application, as the built-in server is not suitable for production.

Remember to open up the necessary port (3000 by default) on your server if you have a firewall running.

If you run into any issues or have additional questions, feel free to ask!

Thank you I will try this.❤️

I have installed React. When I try and create an app, I get this message:

npm install --no-audit --save --save-exact --loglevel error
 react react-dom react-scripts cra-template has failed.
 ``

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.