` no such file or directory` shows when use `React.lazy`
See original GitHub issueI have never modified the following default config.
webpack.config.renderer.dev.babel.js
output: {
publicPath: `http://localhost:${port}/dist/`,
filename: 'renderer.dev.js'
},
webpack.config.renderer.prod.babel.js
output: {
path: path.join(__dirname, '..', 'app/dist'),
publicPath: './dist/',
filename: 'renderer.prod.js'
},
Everything works well, until I use React.lazy
App.js
const LazyMyHome = React.lazy(() => import('./Home'));
const MyHome = props => (
<Suspense fallback={<span>Loading...</span>}>
<LazyCreateProfile {...props} />
</Suspense>
);
...
<Route path="/" key="home" component={MyHome} />
...
npm run dev is ok while npm run start shows error in console.It looks like publicPath didn’t work.

In fact, …/auto-perf-tool/app/dist/0.renderer.prod.js is the correct path.
Has anyone encountered the same problem?🥺
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Building static HTML for pageserror: Error: ENOENT: no such ...
lazy suspense in your component which doesn't support server-side render, you need to remove it by any possible way. then try this should...
Read more >Lazy loading in React - LoginRadius Blog
We will perform lazy loading with React suspense and without it. · First of all, create the app using npm create-react-app npm create-react-app...
Read more >Lazy Loading React Components (with react.lazy and suspense)
It is a new function in react that lets you load react components lazily through code splitting without help from any additional libraries....
Read more >Code-Splitting - React
Most React apps will have their files “bundled” using tools like Webpack, ... (such as a loading indicator) while we're waiting for the...
Read more >How To Handle Async Data Loading, Lazy Loading, and Code ...
In future versions of React, you'll be able to use Suspense to load data in nested components without render blocking. In this tutorial,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Unforgiven-wanda Actually, I am using
React.lazywithpreload: path.join(__dirname, 'dist/renderer.prod.js'). In this problem, it looks like the subpathdistis lost, maybe you can find something in webpack, and according to<script defer src="${script}"><\script>(whennodeIntegration: true) , only files in the same directory as app.html can be requested.Apparently, it is unwise to put bundle files toappdirectory. The above are all my thoughts on this issue, and I don’t have time to continue researching, I hope it can help you.Hello, I have the same issue. Did anybody find a solution how to fix it? Thanks