Gatsby builds suddenly failing with error "Generating JavaScript bundles failed"

As of yesterday, I have noticed that all Gatsby builds are failing with the following error messages. This also happens on my local machine (macOS), so I am thinking that a dependency failure after an update, but the level of logging does not help me pinpoint the error. Similar error messages I have researched are usually followed by an actual error message!

failed Building production JavaScript and CSS bundles - 20.197s
4:35:38 PM: error Generating JavaScript bundles failed
4:35:38 PM: /opt/build/repo/src/components/hero.js:
4:35:38 PM: error Generating JavaScript bundles failed
4:35:38 PM: /opt/build/repo/src/components/layout.js:
error Generating JavaScript bundles failed
4:35:38 PM: /opt/build/repo/src/pages/404.js:
4:35:38 PM: error Generating JavaScript bundles failed
4:35:38 PM: /opt/build/repo/src/pages/about.js:
4:35:38 PM: error Generating JavaScript bundles failed
4:35:38 PM: /opt/build/repo/src/pages/index.js:

… THIS CONTINUES FOR ALL PAGES AND COMPONENTS …

not finished Generating image thumbnails - 23.834s
4:35:38 PM: ​
4:35:38 PM: ┌─────────────────────────────┐
4:35:38 PM: │ “build.command” failed │
4:35:38 PM: └─────────────────────────────┘
4:35:38 PM: ​
4:35:38 PM: Error message
4:35:38 PM: Command failed with exit code 1: gatsby build

There are no other error messages being logged, and I would like to know how I am able to get more logging detail. I have tried gatsby --verbose, but this produces no more logging.

Many thanks, Ian

hey Ian, I think that your idea around this being a failure due to a dependency upgrade is likely accurate, especially as the issue isn’t specific to netlify if it occurs locally.

Your best bet here is to stop trying to make the deploy work onto our servers (and save your build minutes) and get a local build to work first. Then, be sure to commit the package-lock file along with your package.json, so that you have the blueprint for a working config deployed.

Then, you’ll want to choose “clear cache and redeploy” so you get a fresh set of dependencies. Again, this’ll only work if you’ve already got a working config locally, so that has to happen first.

Best of luck - hit us up again if you can’t remediate.

Many thanks for the response. Yes, I intend to fix locally before the next deployment to Netlify. However, I am struggling with fault finding as the level of logging in Gatsby does not seem very high, so hard to find the issue with such a generic error message.

Cheers,
Ian

I have managed to solve this issue. I have replaced the following line in all js files:

import { tw, styled } from “twin.macro”

with an updated import statement.

import tw, { styled } from 'twin.macro’

Now the site compiles correctly. It is strange that the errors started to be generated without any site changes, so I am assuming that there must have been a recent change in the plugin that caused it to suddenly fail.

Very glad to hear that this mystery has been solved- and many thanks for sharing the fix.