部署React应用程序到GitHub Pages时遇到的挑战
P粉611456309
P粉611456309 2023-08-16 15:59:12
0
1
395
<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>
P粉611456309
P粉611456309

全部回复(1)
P粉141925181

看起来你没有在package.json中定义任务(自己检查一下)。由于你正在使用React,请确保已安装gh-pages npm包

npm install gh-pages --save-dev

此外,你还需要在package.json文件的scripts对象下定义任务:

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

例如,我的一个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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!