Heroku 构建失败 - 推送被拒绝,无法编译 node.js 应用程序,无法缩小包,许多错误
Posted
技术标签:
【中文标题】Heroku 构建失败 - 推送被拒绝,无法编译 node.js 应用程序,无法缩小包,许多错误【英文标题】:Heroku build failed - Push rejected, failed to compile node.js app, failed to minify the bundle, many errors 【发布时间】:2019-06-27 04:53:45 【问题描述】:大约 12 小时前,我能够成功部署我的 MERN 堆栈应用程序。从那以后,我没有进行任何有效的更改,并且再次部署到 Heroku 一次又一次地失败。只有我的本地主机,该应用程序运行完美,并且之前成功的 Heroku 构建目前已经上线并且可以正常运行。但是,由于这个原因,我无法将新的更新推送到实时应用程序。
构建日志:
Creating an optimized production build...
Failed to compile.
Failed to minify the bundle. Error: static/js/main.e01c6616.chunk.js from Terser
TypeError: Cannot read property 'minify' of undefined
at compiler.run (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/react-scripts/scripts/build.js:164:23)
at finalCallback (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/webpack/lib/Compiler.js:210:39)
at hooks.done.callAsync.err (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/webpack/lib/Compiler.js:226:13)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/tapable/lib/Hook.js:154:20)
at onCompiled (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/webpack/lib/Compiler.js:224:21)
at hooks.afterCompile.callAsync.err (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/webpack/lib/Compiler.js:553:14)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/tapable/lib/Hook.js:154:20)
at compilation.seal.err (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/webpack/lib/Compiler.js:550:30)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/tapable/lib/Hook.js:154:20)
at hooks.optimizeAssets.callAsync.err (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/webpack/lib/Compilation.js:1295:35)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/tapable/lib/Hook.js:154:20)
at hooks.optimizeChunkAssets.callAsync.err (/tmp/build_0b7573e23cc40b96799733b6dbbf2347/client/node_modules/webpack/lib/Compilation.js:1286:32)
Read more here: http://bit ly CRA-build-minify
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client@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! /tmp/npmcache.PRRnP/_logs/2019-02-03T01_50_06_433Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
我已尝试回滚到以前的版本,但仍然收到此错误。我尝试将一个完全不同的应用程序部署到其现有的实时 Heroku 实例中,但也失败了。过去 12 小时内发生了一些事情。
我看到了这个链接:https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 但我的 react-scripts 版本是 2.0.6。
不确定压缩包失败是什么意思。而且我不确定为什么我无法部署完全不同的应用程序。谁能帮我解决这个问题?
【问题讨论】:
看起来这可能是 Heroku 问题:***.com/questions/54499380/… 【参考方案1】:Terser 是原因。尝试更新它,然后重试,它应该可以工作。
npm install terser@3.14.1 --save-dev
【讨论】:
【参考方案2】:我遇到了同样的问题。我从 .git-ignore 中删除了我的包锁,它起作用了。希望对您有所帮助。
【讨论】:
以上是关于Heroku 构建失败 - 推送被拒绝,无法编译 node.js 应用程序,无法缩小包,许多错误的主要内容,如果未能解决你的问题,请参考以下文章
Heroku 推送被拒绝,无法通过 Bundler 安装 gem
Heroku Symfony 3.2 Push 被拒绝,无法编译 PHP 应用程序