I have only just started using Digital Ocean. I have installed npm. I want to install React.
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!
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:
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.
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.
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
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
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.
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.
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!
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.
``
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.