Heroku的构建失败 - 推否决,未能编译node.js的应用程序,未能再缩小束,许多错误

时间:2019-02-03 02:14:36

标签: node.js reactjs heroku

大约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实例,并且ALSO失败了。事情发生在过去的12小时。

我看到了以下链接:https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify,但是我的react-scripts版本是2.0.6。

不确定缩小包是否失败。而且我不确定为什么无法部署完全不同的应用程序。任何人都可以帮助我解决这个?

2 个答案:

答案 0 :(得分:0)

Terser是原因。尝试更新它,然后再试一次,它应该可以工作。

npm install terser@3.14.1 --save-dev

答案 1 :(得分:0)

我也有同样的问题。我从.git-ignore删除了包锁,它起作用了。希望对您有所帮助。