0
votes

Our deploy code hasn't changed, and our Webpack version ("webpack": "^4.41.0") hasn't changed, and deploys still work successfully for other (non-Heroku) servers.

However, just a couple days ago, Heroku deploy stopped working with this error:

2878 <s> [webpack.Progress] 70% building 4114/4114 modules 0 active 2879 npm ERR! code ELIFECYCLE 2880 npm ERR! errno 1 2881 npm ERR! [email protected] build-heroku: 'npm run clean && webpack --progress --bail --env dist -p' 2882 npm ERR! Exit status 1 2883 npm ERR! 2884 npm ERR! Failed at the [email protected] build-heroku script.

Our /package.json has:

"heroku-postbuild": "cd frontend && npm install --only=dev && npm install && npm run build"

And our /frontend/package.json has:

"scripts": {

"clean": "rimraf dist/*",

"build": "npm run clean && webpack --progress --bail --env dist -p && rm -r prod 2>/dev/null || : && mv dist prod"

}

So why does Webpack build only get to 70% in Heroku now? Has anyone else seen this happen?

1

1 Answers

0
votes

Turns out we weren't reading the log in full. There was errors in the middle of it which weren't appearing at the end. We literally had to search the raw log file for the word "error".

For example:

ModuleNotFoundError: Module not found: Error: Can't resolve 'dns' in '/tmp/build_e65fff75f8ffc7b45670e320e578bd35/frontend/node_modules/mongodb/lib/core'

The solution involved several steps:

  1. Installing some of the modules (ie npm install x)
  2. Adding this block to Webpack config:

    node: { fs: 'empty', net: 'empty', tls: 'empty', dns: 'empty' }

  3. Stopping using the ruby image in our .gitlab-ci.yml file: enter image description here