Actually, I created my first React JS application using the create-react-app from cmd line.
Before running npm run build
Now the problem is that the GitHub page shows 404. when I move to username.github.io/project-name/public the console shows 400 error and a blank page
After running npm run build
Compiled successfully.
File sizes after gzip:
39.92 KB build\static\js\main.a7e4b607.js
109 B build\static\css\main.65027555.css
The project was built assuming it is hosted at /project-name/.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
To publish it at http://username.github.io/project-name, run:
npm install --save-dev gh-pages
Add the following script in your package.json.
// ...
"scripts": {
// ...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
Then run:
npm run deploy
After running the npm run deploy I get this error.
error: failed to execute prompt script (exit code 1) fatal: could not read Username for 'https://github.com': No error
How to fix this error? Can we host react js app on GitHub pages that don't require the database?
Edit - My package.json file
{
"name": "project-name",
"version": "0.1.0",
"private": true,
"homepage": "https://username.github.io/project-name",
"dependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-scripts": "1.0.14"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"devDependencies": {
"gh-pages": "^1.0.0"
}
}
This is what I have in my package.json file.
homepageproperty to your package.json as it states here?