React Application Deployment Issues [duplicate] - reactjs

I am trying to deploy my react app to the GitHub pages but I have encountered the following error:
The build folder is ready to be deployed.
To publish it at https://jatinkumarg.github.io/personal-portfolio, run:
npm run deploy
> personal-portfolio#0.1.0 deploy C:\react-projects\personal-portfolio
> gh-pages -d build
Cloning into 'node_modules\gh-pages\.cache\git#github.com!jatinkumarg!personal-portfolio.git'...
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! personal-portfolio#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the personal-portfolio#0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jatin\AppData\Roaming\npm-cache\_logs\2019-07-23T04_40_54_788Z-debug.log
I have already set-up and tested my ssh key, it works fine.
There is only one remote url i.e. origin(SSH)
This is my package.json
{
"name": "personal-portfolio",
"version": "0.1.0",
"homepage": "https://jatinkumarg.github.io/personal-portfolio",
"dependencies": {
"jquery": "^3.4.1",
"json-loader": "^0.5.7",
"react": "^15.5.4",
"react-dom": "^15.5.4"
},
"devDependencies": {
"gh-pages": "^1.0.0",
"react-scripts": "1.0.1"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
At this point, I have no idea what's wrong. Can anyone please help me with this issue?

You need the PRO plan to use GitHub pages on a private repository.
You can try adding a SSH identity in ~/.ssh/config
Host github.com
HostName github.com
User git
IdentityFile /Users/myusername/.ssh/my_github_ssh_private_key_registered_on_github

it didnt help me, but here is my solution:
git remote set-url origin https://github.com/USERNAME/REPOSITORY_NAME.git
You will recieve smtn like this:
npm run deploy
> ravenous#0.1.0 predeploy C:\Users\peter\ravenous
> npm run build
> ravenous#0.1.0 build C:\Users\peter\ravenous
> react-scripts build
Creating an optimized production build...
Compiled with warnings.
./src/components/SearchBar/SearchBar.js
Line 84:21: The href attribute is required for an anchor to be keyboard accessible. Provide a valid, navigable address as the href value. If you cannot provide an href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid
./src/components/Business/Business.js
Line 9:55: Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener react/jsx-no-target-blank
Line 17:21: Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener react/jsx-no-target-blank
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
File sizes after gzip:
40.23 KB build\static\js\2.c4f174a4.chunk.js
1.76 KB build\static\js\main.f787394e.chunk.js
1.08 KB build\static\css\main.551e99bf.chunk.css
783 B build\static\js\runtime-main.647a42cc.js
The project was built assuming it is hosted at /personalportfolio/.
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://PetrMitin.github.io/personalportfolio , run:
npm run deploy
Find out more about deployment here:
bit.ly/CRA-deploy
> ravenous#0.1.0 deploy C:\Users\peter\ravenous
> gh-pages -d build
*** Please tell me who you are.
Run
git config --global user.email "you#example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'peter#LAPTOP-FRARNQJG.(none)')
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ravenous#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ravenous#0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\peter\AppData\Roaming\npm-cache\_logs\2020-01-07T23_02_19_256Z-debug.log
If you did, you are on the right way!
Then pass required info by entering in cmd or whatever:
git config --global user.email "you#example.com"
git config --global user.name "Your Name"
And try to run:
npm run deploy
I believe that i`ve helped you to resolve your question.

Related

webpack-cli Running multiple commands at the same time is not possible

I am trying to made a full stack project using react and django from the tuto of bad traversy of react and django here react it is a django app i flow the tuto and when it coming to excute the flowing command npm run dev and dev it is "dev":" webpack --mode development ./leadmanager/frontend/src/index.js --output-path ./leadmanager/frontend/static/main.js",
i have some errors they are
(venv) youssef#youssef-HP-EliteBook-840-G3:~/Desktop/fullstack$ npm run dev
> fullstack#1.0.0 dev /home/youssef/Desktop/fullstack
> webpack --mode development ./leadmanager/frontend/src/index.js --output-path ./leadmanager/frontend/static/
[webpack-cli] Running multiple commands at the same time is not possible
[webpack-cli Found commands: 'bundle', './leadmanager/frontend/src/index.js'
webpack-cli Run 'webpack --help' to see available commands and options
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! fullstack#1.0.0 dev: webpack --mode development ./leadmanager/frontend/src/index.js --output-path ./leadmanager/frontend/static/
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the fullstack#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/youssef/.npm/_logs/2020-12-29T13_19_24_663Z-debug.log
From docs try to use it as following:
webpack --mode development --entry ./leadmanager/frontend/src/index.js --output-path ./leadmanager/frontend/static/main.js
Notice the --entry
And also you might want to change --output-path part to look like: --output-path ./leadmanager/frontend/static/frontend/
Not certain if it's a bug or if there's an updated format to the scripts, but rolling back to webpack-cli verson 4.2.0 works.
npm i -D webpack-cli#4.2.0
As PaulESPN mentioned, it looks like it’s a bug in the latest cli (4.3.0) The workaround it’s to explicitly list the command first, I.e. webpack serve where you replace serve with the command you’re trying to use.

Why I get an error when I try to deploy a react app to GitHub Pages?

I tried to deploy a react app to GitHub pages...
Commands on package.json:
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
and received this error:
The "file" argument must be of type string. Received type undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
It was supposed to deploy.
I've resolved mine. Newer version 2.1 has some issue. Revert back to 2.0.1.
Reinstall Github pages with a specific version:
npm uninstall gh-pages
npm i gh-pages#2.0.1
npm run deploy // as usual
Hope that helped. :)

gh-pages -d build fails on 'npm run deploy'

I am trying to deploy my react app to the GitHub pages but I have encountered the following error:
The build folder is ready to be deployed.
To publish it at https://jatinkumarg.github.io/personal-portfolio, run:
npm run deploy
> personal-portfolio#0.1.0 deploy C:\react-projects\personal-portfolio
> gh-pages -d build
Cloning into 'node_modules\gh-pages\.cache\git#github.com!jatinkumarg!personal-portfolio.git'...
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! personal-portfolio#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the personal-portfolio#0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jatin\AppData\Roaming\npm-cache\_logs\2019-07-23T04_40_54_788Z-debug.log
I have already set-up and tested my ssh key, it works fine.
There is only one remote url i.e. origin(SSH)
This is my package.json
{
"name": "personal-portfolio",
"version": "0.1.0",
"homepage": "https://jatinkumarg.github.io/personal-portfolio",
"dependencies": {
"jquery": "^3.4.1",
"json-loader": "^0.5.7",
"react": "^15.5.4",
"react-dom": "^15.5.4"
},
"devDependencies": {
"gh-pages": "^1.0.0",
"react-scripts": "1.0.1"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
At this point, I have no idea what's wrong. Can anyone please help me with this issue?
You need the PRO plan to use GitHub pages on a private repository.
You can try adding a SSH identity in ~/.ssh/config
Host github.com
HostName github.com
User git
IdentityFile /Users/myusername/.ssh/my_github_ssh_private_key_registered_on_github
it didnt help me, but here is my solution:
git remote set-url origin https://github.com/USERNAME/REPOSITORY_NAME.git
You will recieve smtn like this:
npm run deploy
> ravenous#0.1.0 predeploy C:\Users\peter\ravenous
> npm run build
> ravenous#0.1.0 build C:\Users\peter\ravenous
> react-scripts build
Creating an optimized production build...
Compiled with warnings.
./src/components/SearchBar/SearchBar.js
Line 84:21: The href attribute is required for an anchor to be keyboard accessible. Provide a valid, navigable address as the href value. If you cannot provide an href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid
./src/components/Business/Business.js
Line 9:55: Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener react/jsx-no-target-blank
Line 17:21: Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener react/jsx-no-target-blank
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
File sizes after gzip:
40.23 KB build\static\js\2.c4f174a4.chunk.js
1.76 KB build\static\js\main.f787394e.chunk.js
1.08 KB build\static\css\main.551e99bf.chunk.css
783 B build\static\js\runtime-main.647a42cc.js
The project was built assuming it is hosted at /personalportfolio/.
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://PetrMitin.github.io/personalportfolio , run:
npm run deploy
Find out more about deployment here:
bit.ly/CRA-deploy
> ravenous#0.1.0 deploy C:\Users\peter\ravenous
> gh-pages -d build
*** Please tell me who you are.
Run
git config --global user.email "you#example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'peter#LAPTOP-FRARNQJG.(none)')
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ravenous#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ravenous#0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\peter\AppData\Roaming\npm-cache\_logs\2020-01-07T23_02_19_256Z-debug.log
If you did, you are on the right way!
Then pass required info by entering in cmd or whatever:
git config --global user.email "you#example.com"
git config --global user.name "Your Name"
And try to run:
npm run deploy
I believe that i`ve helped you to resolve your question.

ReactJS web application Permission error when deploy rty to build

I'm stuck at deploying my reactJS web application to Heroku.
It worked fine on the local machine. I got problems with permission when Build section runs.
I don't know what did I wrong, everything else in this course works fine.
I tried to deploy the app with GitHub connection, but I got the same error.
I tried to run this code in terminal NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client, but I got another error (NPM... is not a command).
my package.json file :
{
"name": "contactkeeper",
"version": "1.0.0",
"description": "Contact manager app",
"main": "server.js",
"engines": {
"node": "^12.4.0"
},
"scripts": {
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"clientinstall": "npm install --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"keywords": [],
"author": "vinogitz",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"config": "^3.1.0",
"express": "^4.17.1",
"express-validator": "^6.1.1",
"jsonwebtoken": "^8.5.1",
"lodash.template": "^4.5.0",
"mongoose": "^5.6.3"
},
"devDependencies": {
"concurrently": "^4.1.1",
"nodemon": "^1.19.1"
}
}
my gitignore like this:
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
#client/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
-----> Build
Running heroku-postbuild
> contactkeeper#1.0.0 heroku-postbuild /tmp/build_5e4bd7bd79fb3c0f84bb21cb820d7594
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
audited 902208 packages in 13.316s
found 0 vulnerabilities
> client#0.1.0 build /tmp/build_5e4bd7bd79fb3c0f84bb21cb820d7594/client
> react-scripts build
sh: 1: react-scripts: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! client#0.1.0 build: `react-scripts build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the client#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.BWDxV/_logs/2019-07-22T11_55_03_878Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! contactkeeper#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the contactkeeper#1.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.BWDxV/_logs/2019-07-22T11_55_03_893Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
I found the problem. the permission denied is not the perfect error message, but i found the solution.
I tried to ignore the node_modules folder in my client folder with .gitignore, but I didn't find the solution first time, so I just delete the sub folder node_modules from project. After that, I tried to deploy it again, and it's worked. So the real problem was that, the git add, git commit, git push commands pushed the node_modules sub folder to the repository.
PS.: The solution is: write node_modules/ instead of /node_modules in gitignore. With this the node_modules folders in a project (root folder or in a sub folder get untracked.)
Thanks!

npm start gives error `webpack-dev-server: not found` even if it is installed

In package.json devDependencies I have webpack-dev-server installed:
"webpack-dev-server": "3.2.1"
but when I run the start script, which looks as follows:
"start": "webpack-dev-server --inline --config demo/webpack.config.js --port 9000 --mode development"
I get this error:
sh: 1: webpack-dev-server: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! your-app#2.0.5 start: `webpack-dev-server --inline --config demo/webpack.config.js --port 9000 --mode development`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the your-app#2.0.5 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
What is the issue here?
Notice that every script you want access in cli, script should be install in your system as globally.
you can install globally every script you want with npm. that way add -g in your command when you want install package.
In your case, you should run this command:
npm install webpack-dev-server -g
after that you can access webpack-dev-server in your command. like your code webpack-dev-server added to start script in your package.json file.
After that, you can run npm install webpack-dev-server --save-dev command to add this package in your node_modules.
Now, you have access webpack-dev-server in your cli. As you write in your start script in your package.json.
My app by default, did a "production" install, which didn't install devDepencies.
I did:
export NODE_ENV=development
before executing npm install and it installed dev dependecies, so now it works.

Resources