Creating a production build in React for GoDaddy

Creating a production build in React for GoDaddy

I needed to upload a production build of my project to serve live on GoDaddy and I encountered an issue, the homepage link was missing that needed to added to the website to be displayed. If you encountered the same issue, this should help.

What you need to install:
A dotenv package to process your .env file.


Use npm install dotenv or yarn add dotenv provided you have either as your package manager

Files needed: .env and package.json

Step 1:
Create a .env in project's home directory.

Step 2:
In your package.json.

Right after the version of you app, add the link to website in this format.

homepage”: “http://www.mywebsitelink.com”

Step 3:
Run npm run build or yarn build, if you are using yarn on your project.

Step 4:
In your .env.

Add the parameter PUBLIC_URL to your .env and the value will be http://www.mywebsitelink.com your website's homepage address, the same value as the homepage value in your package.json. You should have something like this:

PUBLIC_URL=http://www.mywebsitelink.com

Lastly, run the command to build your files again and everything will be in order now. Happy coding !!!

Picture from undraw