[英]npm run deploy is not working, can't deploy react app to github
[英]React - I can't deploy to github with npm run deploy
首先,我创建了存储库。 然后我什么时候到终端并输入git init
,然后git add.
, and then I took these commands from github and pasted in terminal: git commit -m "first commit" git branch -M main git remote add origin https://githubl.com/igora45/ReactShoppingEcommerce.git git push -u origin main
然后我安装了: npm i gh-pages --save-dev
。 然后我转到我的package.json
文件并放置"homepage": "https://igora45.github.io/ReactShoppingEcommerce"
,然后在package.json
的“脚本”中,我仍然"predeploy": "npm run build", "deploy": "gh-pages -d build",
然后,转到终端并输入git add.
, git commit -m "deploy"
,然后git push
,最后npm run deploy
。
我正在尝试使用npm run deploy
我的 React 应用程序部署到 github,自从我尝试解决此问题 20 小时后这就无法正常工作
我的package.json
PACKAGE.JSON
在我的终端中,当我写npm run deploy
时: TERMINAL
我试图从我的.gitignore
中删除“dist”和“dist-ssr”,但我无法解决这个问题。 我在 package.json 的scripts
中添加了"heroku-postbuild": "cd client && npm install && npm run build"
,但仍然无法正常工作。
我也尝试部署到 .netlify,但出现了几个错误。
当您说gh -d build
时,这意味着您要部署build
文件夹。
但我看到您的 output 文件夹是dist
而不是build
尝试将其更改为gh-pages -d dist
还要检查您是否在 GitHub 项目仓库中启用了gh-pages
。
settings
选项卡pages
选项gh-pages
而不是master
在自定义构建 output 路径上查看此答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.