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

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

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

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel