将React App部署到Git Hub页面失败

时间:2018-07-20 13:15:16

标签: reactjs github-pages create-react-app

我正在尝试将我的React应用程序部署到github页面上............

遵循了一个教程,并设法使其适用于先前的项目。 当我运行npm run deploy时出现此错误 任何帮助将不胜感激如何解释这个错误 我尝试了在这里找到的其他解决方案,但没有帮助

npm运行部署

> Neighbourhood-Map-React@0.1.0 predeploy C:\Users\mels_\Documents\Neighbourhood-Map-React
> npm run build


> Neighbourhood-Map-React@0.1.0 build C:\Users\mels_\Documents\Neighbourhood-Map-React
> react-scripts build

   Creating an optimized production build...
   Failed to compile.

   Error: Parse Error: <meta name="viewport" content="width=device-width, initial  
     -scale=1>
      <meta name="theme-color" content="#000000">
      <!--
        manifest.json provides metadata used when your web app is added to the
        homescreen on Android. See https://developers.google.com/web/fundamental  
      s/engage-and-retain/web-app-manifest/
      -->
      <link rel="manifest" href="/github.io/Neighbourhood-Map-React/manifest.jso  n">
      <link rel="shortcut icon" href="/github.io/Neighbourhood-Map-React/favicon  .ico">
      <!--
        Notice the use of /github.io/Neighbourhood-Map-React in the tags above.
        It will be replaced with the URL of the `public` folder during the build  .
        Only files inside the `public` folder can be referenced from the HTML.
        Unlike "/favicon.ico" or "favicon.ico", "/github.io/Neighbourhood-Map-Re  act/favicon.ico" will
        work correctly both with client-side routing and a non-root public URL.
        Learn how to configure a non-root public URL by running `npm run build`.      -->
      <title>React App</title>
    <link href="/github.io/Neighbourhood-Map-React/static/css/main.c066d278.css"   rel="stylesheet"></head>
    <body>
      <noscript>
        You need to enable JavaScript to run this app.
      </noscript>
      <div id="root"></div>
      <!--
        This HTML file is a template.
        If you open it directly in the browser, you will see an empty page.
        You can add webfonts, meta tags, or analytics to this file.
        The build step will place the bundled scripts into the <body> tag.
        To begin the development, run `npm start` or `yarn start`.
        To create a production bundle, use `npm run build` or `yarn build`.
      -->
    <script type="text/javascript" src="/github.io/Neighbourhood-Map-React/stati  c/js/main.df359430.js"></script></body>
  </html>

  - htmlparser.js:240 new HTMLParser
    [Neighbourhood-Map-React]/[html-minifier]/src/htmlparser.js:240:13

  - htmlminifier.js:951 minify
    [Neighbourhood-Map-React]/[html-minifier]/src/htmlminifier.js:951:3

  - htmlminifier.js:1306 exports.minify
    [Neighbourhood-Map-React]/[html-minifier]/src/htmlminifier.js:1306:16

  - index.js:296
    [Neighbourhood-Map-React]/[html-webpack-plugin]/index.js:296:16

  - util.js:16 tryCatcher
    [Neighbourhood-Map-React]/[bluebird]/js/release/util.js:16:23

  - promise.js:512 Promise._settlePromiseFromHandler
    [Neighbourhood-Map-React]/[bluebird]/js/release/promise.js:512:31

  - promise.js:569 Promise._settlePromise
    [Neighbourhood-Map-React]/[bluebird]/js/release/promise.js:569:18

  - promise.js:614 Promise._settlePromise0
    [Neighbourhood-Map-React]/[bluebird]/js/release/promise.js:614:10

  - promise.js:693 Promise._settlePromises
    [Neighbourhood-Map-React]/[bluebird]/js/release/promise.js:693:18

  - async.js:133 Async._drainQueue
    [Neighbourhood-Map-React]/[bluebird]/js/release/async.js:133:16

  - async.js:143 Async._drainQueues
    [Neighbourhood-Map-React]/[bluebird]/js/release/async.js:143:10

  - async.js:17 Immediate.Async.drainQueues [as _onImmediate]
    [Neighbourhood-Map-React]/[bluebird]/js/release/async.js:17:14


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Neighbourhood-Map-React@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Neighbourhood-Map-React@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!     C:\Users\mels_\AppData\Roaming\npm-cache\_logs\2018-07-20T13_00_54_457Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Neighbourhood-Map-React@0.1.0 predeploy: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Neighbourhood-Map-React@0.1.0 predeploy 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\mels_\AppData\Roaming\npm-cache\_logs\2018-07-20T13_00_54_550Z-debug.log
warning: LF will be replaced by CRLF in package-lock.json.
The file will have its original line endings in your working directory.

2 个答案:

答案 0 :(得分:0)

正如@Orkhan Jafarov指出的那样,您的脚本在解析错误时失败。您在"标记的末尾缺少meta

   Error: Parse Error: <meta name="viewport" content="width=device-width, initial-scale=1>

答案 1 :(得分:-1)

将HTTPS与Git一起使用时,有一些常见错误。这些错误通常表明您使用的是旧版Git,或者您无权访问存储库。 当提示您输入用户名和密码时,请确保您使用有权访问该存储库的帐户。

对于Windows版Git,在命令行中运行以下命令将存储您的凭据:

$ git config --global credential.helper wincred

这称为打开密码缓存