DEV Community

Clarice Bouwer
Clarice Bouwer

Posted on • Updated on

Why you will see the error "Loading chunk \d+ failed"

I know of the following reasons why chunks cannot be downloaded:

  • network errors: inspect the network in the browser dev tools to find out more information about the errors.

  • resources not found: they don't exist in the correct directory (output > publicPath). Try access the resource/asset via its URL in the browser to see if it exists.

  • package corruption: something is wonky with the node_modules. In my case, I manipulated my modules locally to avoid having to push to npm on each change. This caused corruption which resulted in chunks that did exist in the output path were deemed not found. To rectify this, delete the modules and re-install.

  • duplicate styled-components: https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-several-instances-of-module-on-the-page

rm -rf node_modules
npm install # or `npm i` for short
Enter fullscreen mode Exit fullscreen mode

Top comments (0)