任何人都可以帮助我,如何在github上部署我的react应用程序。我已经使用更新的react模块在package.json文件中添加了所有必需的Dependecny。
以下是我的package.json文件:
{
"name": "git-sample-react",
"version": "0.1.0",
"private": true,
"homepage": "https://ababsheck.github.io/first-react-sample/",
"dependencies": {
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-scripts": "1.1.4"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"deploy": "gh-pages -b master -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"gh-pages": "^1.2.0"
}
}
Run Code Online (Sandbox Code Playgroud)
npm运行部署问题:github
Failed to get remote.origin.url (task must either be run in a git repository with a configured origin remote or must be configured with the "repo" option).
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! git-sample-react@0.1.0 deploy: `gh-pages -b master -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the git-sample-react@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\abhis\AppData\Roaming\npm-cache\_logs\2018-08-07T12_21_21_735Z-debug.log
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,在GitHub上部署react应用,并通过以下方法解决了这个问题:
git remote add origin <url>使用GitHub上存储库的URL 在project文件夹中运行命令。npm install --save-dev gh-pages。npm run build。npm run deploy。gh-pages branch。

我还添加了"homepage": "https://ababsheck.github.io/first-react-sample/",
如下脚本之前的内容:
"homepage": "https://ababsheck.github.io/first-react-sample/",
"scripts": {
"predeploy": "npm run build",
...// the rest of the code
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1015 次 |
| 最近记录: |