Gatsby build fails - Can"t resolve "mitt" in "/opt/build/repo/.cache"

Hi @MorayM,

Thanks for reaching out and welcome to Netlify’s Support Forums!

Looking at the latest deploy that failed, I’m seeing these errors:

1:55:02 PM: failed Building production JavaScript and CSS bundles - 15.979s

1:55:02 PM: error Generating JavaScript bundles failed

1:55:02 PM: Can"t resolve "mitt" in "/opt/build/repo/.cache"

1:55:02 PM: If you"re trying to use a package make sure that "mitt" is installed. If you"re trying to use a local file make sure that the path is correct.

1:55:02 PM: error Generating JavaScript bundles failed

1:55:02 PM: Can"t resolve "shallow-compare" in "/opt/build/repo/.cache"

1:55:02 PM: If you"re trying to use a package make sure that "shallow-compare" is installed. If you"re trying to use a local file make sure that the path is correct.

1:55:02 PM: error Generating JavaScript bundles failed

1:55:02 PM: Can"t resolve "@gatsbyjs/reach-router" in "/opt/build/repo/.cache"

1:55:02 PM: If you"re trying to use a package make sure that "@gatsbyjs/reach-router" is installed. If you"re trying to use a local file make sure that the path is correct.

1:55:02 PM: error Generating JavaScript bundles failed

1:55:02 PM: Can"t resolve "gatsby-react-router-scroll" in "/opt/build/repo/.cache"

1:55:02 PM: If you"re trying to use a package make sure that "gatsby-react-router-scroll" is installed. If you"re trying to use a local file make sure that the path is correct.

1:55:02 PM: error Generating JavaScript bundles failed

1:55:02 PM: Can"t resolve "gatsby-link" in "/opt/build/repo/.cache"

1:55:02 PM: If you"re trying to use a package make sure that "gatsby-link" is installed. If you"re trying to use a local file make sure that the path is correct.

1:55:02 PM: error Generating JavaScript bundles failed

1:55:02 PM: Can"t resolve "gatsby-script" in "/opt/build/repo/.cache"

1:55:02 PM: If you"re trying to use a package make sure that "gatsby-script" is installed. If you"re trying to use a local file make sure that the path is correct.

1:55:02 PM: error Generating JavaScript bundles failed

1:55:02 PM: Can"t resolve "@gatsbyjs/reach-router" in "/opt/build/repo/.cache/head"

1:55:02 PM: If you"re trying to use a package make sure that "@gatsbyjs/reach-router" is installed. If you"re trying to use a local file make sure that the path is correct.

1:55:02 PM: error Generating JavaScript bundles failed

1:55:02 PM: Can"t resolve "@gatsbyjs/reach-router" in "/opt/build/repo/.cache"

1:55:02 PM: If you"re trying to use a package make sure that "@gatsbyjs/reach-router" is installed. If you"re trying to use a local file make sure that the path is correct.

1:55:02 PM: error Generating JavaScript bundles failed

1:55:02 PM: Can"t resolve "gatsby-link" in "/opt/build/repo/.cache"

1:55:02 PM: If you"re trying to use a package make sure that "gatsby-link" is installed. If you"re trying to use a local file make sure that the path is correct.

1:55:02 PM: error Generating JavaScript bundles failed

1:55:02 PM: Can"t resolve "prop-types" in "/opt/build/repo/.cache"

1:55:02 PM: If you"re trying to use a package make sure that "prop-types" is installed. If you"re trying to use a local file make sure that the path is correct.

1:55:02 PM: error Generating JavaScript bundles failed

1:55:02 PM: Can"t resolve "@gatsbyjs/reach-router" in "/opt/build/repo/.cache"

1:55:02 PM: If you"re trying to use a package make sure that "@gatsbyjs/reach-router" is installed. If you"re trying to use a local file make sure that the path is correct.

1:55:02 PM: error Generating JavaScript bundles failed

1:55:02 PM: Can"t resolve "gatsby-react-router-scroll" in "/opt/build/repo/.cache"

1:55:02 PM: If you"re trying to use a package make sure that "gatsby-react-router-scroll" is installed. If you"re trying to use a local file make sure that the path is correct.

I found this forum post with a similar issue:

Are you able to follow the solution to see if it resolve your issue?