我正在尝试将我的React应用程序部署到GitHub页面,但是遇到以下错误:
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
这是我的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"
}
}
在这一点上,我不知道出了什么问题。有人可以帮我解决这个问题吗?
答案 0 :(得分:0)
您需要PRO
计划才能在私有存储库上使用GitHub页面。
您可以尝试在〜/ .ssh / config中添加SSH身份
Host github.com
HostName github.com
User git
IdentityFile /Users/myusername/.ssh/my_github_ssh_private_key_registered_on_github
答案 1 :(得分:0)
它没有帮助我,但这是我的解决方案:
git remote set-url origin https://github.com/USERNAME/REPOSITORY_NAME.git
您将收到这样的短信:
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
如果您这样做了,那您就走对了!
然后通过输入cmd或其他内容来传递所需的信息:
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
并尝试运行:
npm run deploy
我相信我已经帮助您解决了您的问题。