简体   繁体   English

当我尝试将 React 应用程序部署到 GitHub Pages 时,为什么会出现错误?

[英]Why I get an error when I try to deploy a react app to GitHub Pages?

I tried to deploy a react app to GitHub pages...我试图将反应应用程序部署到 GitHub 页面...

Commands on package.json: package.json 上的命令:

 "predeploy": "npm run build",
 "deploy": "gh-pages -d build",

and received this error:并收到此错误:

The "file" argument must be of type string. Received type undefined
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.

It was supposed to deploy.它应该部署。

I've resolved mine.我的已经解决了Newer version 2.1 has some issue.较新的 2.1 版有一些问题。 Revert back to 2.0.1.恢复到 2.0.1。

  • Reinstall Github pages with a specific version:重新安装特定版本的 Github 页面:
npm uninstall gh-pages

npm i gh-pages@2.0.1

npm run deploy // as usual

Hope that helped.希望有所帮助。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我无法在github页面上部署React应用 - I can not deploy react app on github pages 如何在 github 页面上部署 React 应用程序? - How can I deploy react app on github pages? 如何在用户页面 (Github) 上部署 React 应用程序? - How do I deploy react app on user pages (Github)? 如何在 GitHub Pages 上部署带有节点后端的 React 应用程序? - How can I deploy a react app with a node backend on GitHub Pages? React App:为什么当我尝试运行 npm start 脚本时出现错误? - React App: Why I get an error when I try to run npm start script? 尝试将 React Project 放在 github 页上,但出现错误:npm ERR:缺少脚本:“部署” - Trying to put React Project on github pages but I get error: npm ERR! Missing script: "deploy" 当我将我的 react 应用程序部署到 gh-pages 时,为什么我会丢失我的图像? - Why do I lose my images when I deploy my react app to gh-pages? 如何从 Github Actions 将 React 应用程序部署到 Github Pages? - How do i deploy a React app to Github Pages from Github Actions? 我尝试部署React Heroku应用时出现无效的主机头错误 - Invalid host header error as I try to deploy a react heroku app 如何在 gh-pages(github 页面)上部署我的 React 应用程序? - How can I deploy my React app on gh-pages (github pages)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM