将响应应用程序部署到github时出现问题

时间:2020-07-02 02:12:06

标签: javascript reactjs github npm command-prompt

我创建了一个在本地主机中正常工作的待办事项列表。 我试图在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

2 个答案:

答案 0 :(得分:0)

我在反应和这些工具方面都不专业。

但是错误日志指出您已经有一个名为“ gh-pages”的分支,请检查您的github存储库并删除它。

答案 1 :(得分:0)

如果稍作搜索,您会发现this

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

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