Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamically / lazily loaded chunks throw an error

See original GitHub issue

Hello, I’m trying to implement this with Angular2. Everything seems to be working fine client side, but SSR is not working with “lazy-loaded” chunks Error: Cannot find module './0.server.js'.

I tried using LimitChunkCountPlugin but the rabbit hole seemed to be deeper. Now I looked at the MemoryFileSystem and the file is definitely there.

Eventually I got it to work, but I had to run a build before running the server, which is weird, it seems like it needs the disk files to be there before starting, but it still uses the memory files. I know it doesn’t use disk files because deleting their content doesn’t change the outcome, and changes to /src files (i.e. rebuilding) doesn’t change them, however, if I delete the file from disk, it bugs out again. 😕

Here’s the branch I’m working on

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

amangeotcommented, Sep 12, 2017

I think I get a similar error when I import my files dynamically It works fine with a static import: import ExploreView from './containers/ExploreView'

but with a dynamic import:

import Loadable from 'react-loadable'
export const ExploreView = Loadable({
  loader: () => import(/* webpackChunkName: "explore" */ './containers/ExploreView'),
  loading: () => null,

Error: Cannot find module ‘./2.serverRenderer.js’ at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Function.requireEnsure [as e] (C:\Users\Adrien\Documents\Dev\front-end-ssr\dist\server\webpack:\webpack\bootstrap 134319b5727946bc9a01:39:1) at loader (C:\Users\Adrien\Documents\Dev\front-end-ssr\dist\server\webpack:\src\universal\routes\explore\index.js:9:17) at C:\Users\Adrien\Documents\Dev\front-end-ssr\node_modules\react-loadable\lib\index.js:28:12 at capture (C:\Users\Adrien\Documents\Dev\front-end-ssr\node_modules\react-loadable\lib\index.js:21:17) at load (C:\Users\Adrien\Documents\Dev\front-end-ssr\node_modules\react-loadable\lib\index.js:27:18) at new LoadableComponent (C:\Users\Adrien\Documents\Dev\front-end-ssr\node_modules\react-loadable\lib\index.js:149:15) at C:\Users\Adrien\Documents\Dev\front-end-ssr\node_modules\react-dom\lib\ReactCompositeComponent.js:294:18 at measureLifeCyclePerf (C:\Users\Adrien\Documents\Dev\front-end-ssr\node_modules\react-dom\lib\ReactCompositeComponent.js:75:12) at ReactCompositeComponentWrapper._constructComponentWithoutOwner (C:\Users\Adrien\Documents\Dev\front-end-ssr\node_modules\react-dom\lib\ReactCompositeComponent.js:293:16) at ReactCompositeComponentWrapper._constructComponent (C:\Users\Adrien\Documents\Dev\front-end-ssr\node_modules\react-dom\lib\ReactCompositeComponent.js:279:21) at ReactCompositeComponentWrapper.mountComponent (C:\Users\Adrien\Documents\Dev\front-end-ssr\node_modules\react-dom\lib\ReactCompositeComponent.js:187:21) at Object.mountComponent (C:\Users\Adrien\Documents\Dev\front-end-ssr\node_modules\react-dom\lib\ReactReconciler.js:45:35)

StevenLangbroekcommented, Mar 20, 2019

(I’m investigating clearing the require cache after compile as an alternative solution)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Solve the Chunk Load Error in JavaScript - Rollbar
Whenever there's an error observed in dynamically fetching helper JavaScript files known as Chunks, a ChunkLoad Error is thrown.
Read more >
Retry Loading Failed Code Split Chunks
Code splitting is achieved through the dynamic import syntax. This returns a promise that is fulfilled when the chunk is successfully loaded.
Read more >
Dynamic Import, Code Splitting, Lazy Loading, and Error ...
If we code something like import(someVariable) , Webpack throws an error. What is code splitting? It is a feature to split the code...
Read more >
React — Loading Chunk Failed Error | by Tushar Mohan
Needs to return a promise resolving to a module having default export (React.lazy requires it). Should not leave the promise object returned ...
Read more >
assets:clean deletes lazy-loaded chunks · Issue #2913 - GitHub
Lazy-loading FTW! However, we've started seeing issues in our error tracker about ChunkLoadError because the assets are missing from the server.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found