将create-react-app应用程序部署到github页面构建正常但不会部署

时间:2018-03-11 22:15:46

标签: reactjs github react-router react-redux github-pages

我有一个使用create-react-app创建的反应应用。它运行正常,我的本地主机没有错误。

我在github上有一个存储库,我在主分支上。当我运行npm run部署应用程序构建时没有任何问题,但是当涉及到部署时,我收到以下消息:

fatal: HttpRequestException encountered.
   An error occurred while sending the request.
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': No error

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.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Gaz\AppData\Roaming\npm-cache\_logs\2018-03-11T22_02_32_295Z-debug.log

完整的日志如下:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\Gaz\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'deploy' ]
2 info using npm@5.7.1
3 info using node@v8.9.3
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info lifecycle my-app@0.1.0~predeploy: my-app@0.1.0
6 verbose lifecycle my-app@0.1.0~predeploy: unsafe-perm in lifecycle true
7 verbose lifecycle my-app@0.1.0~predeploy: PATH: C:\Users\Gaz\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\my-app\node_modules\.bin;C:\Users\Gaz\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Gaz\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\nodejs;C:\Program Files\Git\cmd;C:\Users\Gaz\AppData\Local\Microsoft\WindowsApps;C:\Users\Gaz\AppData\Roaming\npm;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
8 verbose lifecycle my-app@0.1.0~predeploy: CWD: C:\my-app
9 silly lifecycle my-app@0.1.0~predeploy: Args: [ '/d /s /c', 'npm run build' ]
10 silly lifecycle my-app@0.1.0~predeploy: Returned: code: 0  signal: null
11 info lifecycle my-app@0.1.0~deploy: my-app@0.1.0
12 verbose lifecycle my-app@0.1.0~deploy: unsafe-perm in lifecycle true
13 verbose lifecycle my-app@0.1.0~deploy: PATH: C:\Users\Gaz\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\my-app\node_modules\.bin;C:\Users\Gaz\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Gaz\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\nodejs;C:\Program Files\Git\cmd;C:\Users\Gaz\AppData\Local\Microsoft\WindowsApps;C:\Users\Gaz\AppData\Roaming\npm;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
14 verbose lifecycle my-app@0.1.0~deploy: CWD: C:\my-app
15 silly lifecycle my-app@0.1.0~deploy: Args: [ '/d /s /c', 'gh-pages -d build' ]
16 silly lifecycle my-app@0.1.0~deploy: Returned: code: 1  signal: null
17 info lifecycle my-app@0.1.0~deploy: Failed to exec deploy script
18 verbose stack Error: my-app@0.1.0 deploy: `gh-pages -d build`
18 verbose stack Exit status 1
18 verbose stack     at EventEmitter.<anonymous> (C:\Users\Gaz\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
18 verbose stack     at emitTwo (events.js:126:13)
18 verbose stack     at EventEmitter.emit (events.js:214:7)
18 verbose stack     at ChildProcess.<anonymous> (C:\Users\Gaz\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
18 verbose stack     at emitTwo (events.js:126:13)
18 verbose stack     at ChildProcess.emit (events.js:214:7)
18 verbose stack     at maybeClose (internal/child_process.js:925:16)
18 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
19 verbose pkgid my-app@0.1.0
20 verbose cwd C:\my-app
21 verbose Windows_NT 10.0.16299
22 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Gaz\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "deploy"
23 verbose node v8.9.3
24 verbose npm  v5.7.1
25 error code ELIFECYCLE
26 error errno 1
27 error my-app@0.1.0 deploy: `gh-pages -d build`
27 error Exit status 1
28 error Failed at the my-app@0.1.0 deploy script.
28 error This is probably not a problem with npm. There is likely additional logging output above.
29 verbose exit [ 1, true ]

我尝试在我的connectedRouter中使用基础名称添加基础名称(使用react-router-redux),仍然是同样的错误。

我更新了存储库地址以包含我的用户名和密码凭据,以排除任何登录问题。

我将我的存储库重命名为原始名称,认为这可能是问题所在。

我还将创建的构建文件夹重命名为docs,并尝试通过github上的master / docs选项运行github页面(因为似乎没有选项可以手动选择gh-pages分支,就像很多指令一样说有)。我还是没有运气。我确实认为这是我必须要这样做的方式虽然我刚刚意识到当我尝试在github页面上主持master / docs时它实际上在浏览器选项卡上显示我的react-app标题但它确实没有加载任何东西。

我的package.json文件如下所示:

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "homepage": "https://gurtaj1.github.io/Site1",
  "dependencies": {
    "bootstrap-less": "^3.3.8",
    "classnames": "^2.2.5",
    "history": "^4.7.2",
    "immutability-helper": "^2.3.0",
    "lodash": "^4.17.4",
    "paginator": "^1.0.0",
    "prop-types": "^15.6.1",
    "react": "^15.6.2",
    "react-dom": "^15.6.2",
    "react-js-pagination": "^3.0.1",
    "react-redux": "^5.0.5",
    "react-router": "^4.2.0",
    "react-router-dom": "^4.1.1",
    "react-router-redux": "^5.0.0-alpha.9",
    "redux": "^3.7.2",
    "redux-devtools-extension": "^2.13.2",
    "redux-thunk": "^2.2.0"
  },
  "devDependencies": {
    "gh-pages": "^1.1.0",
    "react-scripts": "1.0.6"
  },
  "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"
  }
}

存储库当前最初称为Site1。

这里发生了什么?

是否与我的实际应用程序或我尝试部署它的方式有关?

1 个答案:

答案 0 :(得分:0)

所以我现在设法将我的回购邮件放到我的github页面上。

我没有使用deploy方法,而是使用我在问题中提到的master / docs方法(使用github UI将docs文件夹设置为我的github页面的源代码)。见https://blog.github.com/2016-08-17-simpler-github-pages-publishing/

我认为我在尝试使用deploy方法工作时将repo名称更改为原始名称,并且可能仍然使用旧的构建/构建,而我的历史记录中没有包含基本名称,这是什么原因造成的当我第一次尝试时,这种方法不起作用。

我对使用此方法感到满意,我认为这是现在的popper方法,而不是我最初尝试的部署方法。 虽然我找不到真正的源代码,但github UI表明这样,因为我看到一些指导方针告诉你选择repo的gh-pages分支作为github页面的源代码,但这不再是一个选项,至少不在我的github回购中,它不是。

我希望有同样问题的其他人可以从中得到一些帮助。