【问题标题】:React app deployment failure on heroku "Failed to minify the code from this file"在heroku上反应应用程序部署失败“无法缩小此文件中的代码”
【发布时间】:2019-01-21 23:36:09
【问题描述】:

我使用 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

newsapi/index.js 在第 17 行读取

let API_KEY; // To be set by clients

【问题讨论】:

  • 在收到此错误消息之前您使用了哪些命令?
  • git push heroku master

标签: reactjs heroku


【解决方案1】:

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

【讨论】:

  • newsapi/index.js 在第 17 行读取:let API_KEY; // 由客户端设置。
  • 我尝试在本地 nodemodule/newsapi/index.js 中将 'let' 更改为 'var' 但是当我推送到 heroku master 时,它没有任何区别。我相信这是因为 heroku 不检查我的本地依赖项,它检查已发布的 newsapi 模块。
猜你喜欢
  • 2021-11-03
  • 2016-06-19
  • 2017-08-21
  • 2016-10-20
  • 2020-04-07
  • 2017-12-17
  • 2015-02-28
  • 2018-08-21
  • 1970-01-01
相关资源
最近更新 更多