部署到heroku时出现Webpack错误(npm退出状态2)

时间:2018-06-07 03:08:21

标签: heroku

我的队友和我正在尝试部署到Heroku,我们已经多次收到这个令人困惑的错误/构建失败。

我们已经麻烦的方式包括:

  1. 确保devDependencies在Dependencies中
  2. 删除并重新安装了Wepback
  3. 删除了锁定文件
  4. 清除了npm缓存
  5. 创建了一个新的heroku应用程序并试图以新的开始部署
  6. 这些都没有奏效,我们真的很感激帮助。谢谢!

        remote: -----> Building dependencies
        remote:        Installing node modules (package.json + package-lock)
        remote:
        remote:        > sensation-mapping@0.0.1 postinstall /tmp/build_165cca2bcbc98089b28e7f67a5aa96ab
        remote:        > webpack
        remote:
        remote:        Hash: be40b95d0b5157875598
        remote:        Version: webpack 3.12.0
        remote:        Time: 1767ms
        remote:        Asset    Size  Chunks                    Chunk Names
        remote:        bundle.js  801 kB       0  [emitted]  [big]  main
        remote:        bundle.js.map  943 kB       0  [emitted]         main
        remote:        [12] ./client/index.js 543 bytes {0} [built]
        remote:        + 24 hidden modules
        remote:
        remote:        ERROR in ./client/index.js
        remote:        Module not found: Error: Can't resolve './components/App' in '/tmp/build_165cca2bcbc98089b28e7f67a5aa96ab/client'
        remote:        @ ./client/index.js 11:11-38
        remote:        npm ERR! code ELIFECYCLE
        remote:        npm ERR! errno 2
        remote:        npm ERR! sensation-mapping@0.0.1 postinstall: `webpack`
        remote:        npm ERR! Exit status 2
        remote:        npm ERR!
        remote:        npm ERR! Failed at the sensation-mapping@0.0.1 postinstall script.
        remote:        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
        remote:
        remote:        npm ERR! A complete log of this run can be found in:
        remote:        npm ERR!     /tmp/npmcache.6UwNM/_logs/2018-06-07T02_48_08_002Z-debug.log
        remote:
        remote: -----> Build failed
    

1 个答案:

答案 0 :(得分:0)

您可以尝试解决问题的方法:

  1. 检查日志中是否有任何问题。
  2. 检查代码是否缺少对可能被调用但不存在的模块的引用。
  3. 完成上述步骤后,请尝试再次构建并查看会发生什么情况。