PS C:\Users\Panch\OneDrive\Desktop\Yourself2> npm run deploy npm 错误!缺少脚本:“部署” npm 错误! npm 错误!要查看脚本列表,请运行: npm 错误! npm 运行
npm 错误!可以在以下位置找到此运行的完整日志:C:\Users\Panch\AppData\Local pm-cache_logs�3-08-15T16_47_39_705Z-debug-0.log PS C:\Users\Panch\OneDrive\Desktop\Yourself2>
所有可能的方式
看起来您没有在
package.json
中定义任务(请自行检查)。当您使用 React 时,请确保安装了 gh-pages
npm 包
npm install gh-pages --save-dev
此外,您还需要在文件中的
scripts
对象下定义任务 package.json
:
"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