【问题标题】:problem while deploying react application to github将 React 应用程序部署到 github 时出现问题
【发布时间】:2020-10-22 13:18:33
【问题描述】:

我创建了一个在 localhost 中正常工作的 todolist。 我试图在 github 上部署它,当我在命令 propmt 中运行“$ npm run deploy”时,它显示错误 p

添加主页、预部署、部署属性到 package.json

已安装 gh-pages --save-dev

请帮助我是初学者

这是命令提示错误。


    
C:\Users\Syed\Desktop\project\todolist>npm run deploy

> todolist@0.1.0 predeploy C:\Users\Syed\Desktop\project\todolist
> npm run build


> todolist@0.1.0 build C:\Users\Syed\Desktop\project\todolist
> react-scripts build

Creating an optimized production build...
Compiled with warnings.

./src/App.js
  Line 2:8:    'logo' is defined but never used              no-unused-vars
  Line 52:20:  Expected to return a value in arrow function  array-callback-return

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:

  55.54 KB  build\static\js\2.0512a152.chunk.js
  1.19 KB   build\static\js\main.1e3fd05a.chunk.js
  785 B     build\static\js\runtime-main.ce724f51.js
  657 B     build\static\css\main.362672fb.chunk.css

The project was built assuming it is hosted at /To-Do-List/.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.

Find out more about deployment here:

  bit.ly/CRA-deploy


> todolist@0.1.0 deploy C:\Users\Syed\Desktop\project\todolist
> gh-pages -d build

fatal: A branch named 'gh-pages' already exists.

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! todolist@0.1.0 deploy: `gh-pages -d build`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the todolist@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\Syed\AppData\Roaming\npm-cache\_logs\2020-07-02T01_49_57_997Z-debug.log

【问题讨论】:

    标签: javascript reactjs github npm command-prompt


    【解决方案1】:

    请查看此快速入门guide 您需要先在 GitHub 存储库设置页面上设置 GitHub 页面主页链接。 然后检查源。 然后保存。应该可以的。

    【讨论】:

      【解决方案2】:

      我在 react 和这些工具方面并不专业。

      但错误日志表明您已经有一个名为“gh-pages”的分支检查您的 github 存储库并将其删除。

      【讨论】:

        【解决方案3】:

        如果你稍微搜索一下,你会找到this

        删除node_modules/gh-pages/.cache,然后重试。

        Linux / macOS / Git bash:rm -rf node_modules/gh-pages/.cache

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-12-22
          • 2017-01-26
          • 2014-11-25
          • 2020-10-27
          • 2012-07-08
          • 1970-01-01
          • 2017-11-03
          • 1970-01-01
          相关资源
          最近更新 更多