在Heroku上反应应用程序部署失败“无法缩小此文件中的代码”

时间:2018-08-15 04:08:59

标签: reactjs heroku

我使用create-react-app命令创建了一个React应用,并尝试按照https://github.com/mars/create-react-app-buildpack#quick-start上的说明将其部署在heroku上

但是,当尝试推送到heroku时,我想到了以下构建失败,其中构建日志显示为:

Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file: 
./node_modules/newsapi/index.js:17 
Read more here: 
https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sports-news-app@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sports-news-app@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional 
logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /app/.npm/_logs/2018-08-15T03_41_33_617Z-debug.log
!     Push rejected, failed to compile React.js (create-react-app) multi app.
!     Push failed
第17行的

newsapi / index.js读取

let API_KEY; // To be set by clients

1 个答案:

答案 0 :(得分:0)

如果不看newsapi/index.js,很难说出错误可能是什么。该文件可能包含不受支持或无法缩小的语法。一种解决方案是查看该行是否为导入,并创建该依赖项的本地版本,并删除或更新有问题的语法。