部署React应用程序到GitHub Pages时遇到的挑战
<p><br /></p>
<pre class="brush:php;toolbar:false;">PS C:UsersPanchOneDriveDesktopYourself2> npm run deploy
npm ERR! 缺少脚本: "deploy"
npm ERR!
npm ERR! 要查看脚本列表,请运行:
npm ERR! npm run
npm ERR! 可在此运行的完整日志位于: C:UsersPanchAppDataLocalnpm-cache_logs2023-08-15T16_47_39_705Z-debug-0.log
PS C:UsersPanchOneDriveDesktopYourself2></pre>
<p>所有可能的方式</p>
看起来你没有在
package.json中定义任务(自己检查一下)。由于你正在使用React,请确保已安装gh-pagesnpm包此外,你还需要在
package.json文件的scripts对象下定义任务:例如,我的一个github页面React应用程序有以下内容:
"scripts": { "predeploy": "npm run build", "deploy": "gh-pages -d build", "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" },按照说明获取更详细的答案:https://github.com/gitname/react-gh-pages