The react app is not building using the homepage tag in package.json file . "homepage":"https://entrepreneurcell.com" . After running npm run build , this is what I am getting in console :-
The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.
Please tell me a more efficient way of deploying react app on hostinger or highlight the mistake that i am doing.
Related
I was doing some experiments and as experiment I build the React application manually as follows instead of create-react-app.
Created a folder and the run npm init -y.
Install react, react-dom, and react-scripts.
Added a start script that points to react-scripts start.
Run the application and get the Could not find a required file error for index.html file.
Added index.html with base code and #app div.
Run the application again and then get the Could not find a required file error for index.js file
Added index.js file with App component and wrote render related code.
Run the application and it works.
So, my question is, if I create application in this way, what I'll miss if the same application is created with create-react-app?
React fails to make proper build, even with default app.
I ran commands npx create-react-app my-app then npm run build.
When I open index.html in /build, the site doesn't work and I get following logs:
You can just open a React (or Angular) build by clicking on the HTML file.
What you have to do is the following:
Install any static server module (i.e. serve):
npm install -g serve
In the root directory:
serve -s build
And then your app will be served.
It would be wise to do that before you deploy to any cloud storage or even your own server, but if you are 100% your app works, you can just deploy in on Vercel, Heroku or GitHub pages, they are free.
How can one deploy a create react app to gh-pages?
My packages.json folder has my homepage listed exactly as this: "homepage": "https://mgcraig78.github.io/RoboFriends",
However, the app will not deploy to gh-pages, and when I enter npm run build, the terminal tells me this (which I'm assuming is the issue, but I can't figure out how to fix it): The project was built assuming it is hosted at /RoboFriends/. <- this obviously is not the homepage I have entered into my packages.json file.
Remove the /RoboFriends from your homepage link in package.json to:
"homepage": "https://mgcraig78.github.io"
Then run
npm run build
What you deploy to github is what's inside the build folder that contains index.html
I have an issue where I deploy my React app the images are not showing. Works fine locally. I've set the homepage to a GitHub site http://ryandixon555.github.io/react-board-game and run
npm build
then
npm deploy
but still no images. I've also specified the homepage in the package.json:
"homepage": "http://ryandixon555.github.io/react-board-game"
In the end I gave up and deployed using netlify, following this link and then copying my code over.
I recently created a small website with react app , but after running , npm run build in the browser i find static folder in the browser in debugger , with my whole react app , components and app.js even node_modules , and of course i think , there is something wrong with npm run build , because , this is not how it suppose to work , by the way i'm using nginx and pm2 to connect my back-end to the website , both on the same server to deploy my website , so the question here , is the error here in nginx configuration or on react build script.
Create React App, give you a webpack configuration that by default include the option to include the source on the build.
You need to do this:
1. Eject your create-react-app project by running npm run eject:
2. Open your /config/webpack.config.prod.js.
3. Remove the line who contains the devtool: 'source-map'.
4. Build, and deploy your app again.
With this, you should don't have the source on your browser, check this if you need more information of webpack config: https://webpack.js.org/configuration/devtool/
NOTE: If you don't wanna eject your code, you can use rewire, and don't touch the base code of CRA and instead override with your configuration.
Hope this helps you!