First, you need to update your server
apt get update
Next step you need to install an updated node module(higher than 10)
For my case, I have installed a node version with 14
sudo curl -sL https://rpm.nodesource.com/setup_14.x | bash – in command line. (it includes the rpm file)
sudo yum install nodejs
Now you need to check the node version by typing simply: node –version
Now it’s time to update npm.
sudo npm install -g npm-check-updates
After installation and update of the node and npm we need to create a test project now follow the below steps:
npx create-react-app reactapp
npm start (In your project directory)
3. After compiling your default test project is up and running on your local server with its default port 3000.
4. For accessing react project globally with domain name do some changes in package.json file.
first, modify your script sections start parameter
"start": " HOST=<domainname> PORT=3000 react-scripts start",
you can manually change the port number that you want by changing the port parameter.
white list your port in ip-tables by typing simply :
iptables -I INPUT -p tcp --dport <your port number> -j ACCEPT
5. Accessing your react app with HTTPS:
"start": "HTTPS=true SSL_CRT_FILE=<certificate.pem> SSL_KEY_FILE=<key.pem>HOST=<domain name> PORT=<your port number> react-scripts start",
for creation key and crt file run the commands:
openssl req -nodes -new -x509 -keyout server.key -out server.cert
now re-start your npm server.