将 React 应用程序部署到 github 页面
Posted
技术标签:
【中文标题】将 React 应用程序部署到 github 页面【英文标题】:Deploying react app to github pages 【发布时间】:2017-11-03 19:52:59 【问题描述】:我正在尝试将 react.js 应用程序部署到 github 页面(我正在关注本指南 https://medium.freecodecamp.com/surge-vs-github-pages-deploying-a-create-react-app-project-c0ecbf317089),但是当我运行 npm run deploy 时,我不断收到以下错误
ENOENT: no such file or directory, stat '/Users/name/Documents/Web Dev/100 Web Projects/wikipediaviewer/build'
npm ERR! Darwin 16.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "deploy"
npm ERR! node v6.10.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! wikipediaviewer@1.0.0 deploy: `npm run build&&gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wikipediaviewer@1.0.0 deploy script 'npm run build&&gh-pages -d build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the wikipediaviewer package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run build&&gh-pages -d build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs wikipediaviewer
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls wikipediaviewer
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/name/Documents/Web Dev/100 Web Projects/wikipediaviewer/npm-debug.log
谁能帮我弄清楚我做错了什么?如果我运行 npm run build 它会成功构建。另外我没有使用 create-react-app 来构建这个应用程序,这可能是问题吗?我需要做些什么来解决它。
【问题讨论】:
是的,就是这个问题,非常感谢 【参考方案1】:运行npm run build
之后好像没有创建build文件夹,所以你应该改gh-pages -d path-to-your-build
【讨论】:
以上是关于将 React 应用程序部署到 github 页面的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 Github 工作流程轻松地将 React 和 Gatsby 部署到 github 页面?
获取 404 以获取将 create-react-app 部署到 github 页面的链接
如何创建工作流以将 React & Gatsby 应用程序部署到 Github 页面?