[prerender-spa-plugin] Unable to prerender all routes! when upgrade webpack to v5+
See original GitHub issueERROR in [prerender-spa-plugin] Unable to prerender all routes! this happened in webpack5, but work well in webpack4
node env: v12.18.2
error messages comes out with deeply debug;
webpack5 breaked here because of this:
https://webpack.js.org/blog/2020-10-10-webpack-5-release/#filesystems
Filesystems Next to compiler.inputFileSystem and compiler.outputFileSystem there is a new compiler.intermediateFileSystem for all fs actions that are not considered as input or output, like writing records, cache or profiling output.
The filesystems have now the fs interface and do no longer demand additional methods like join or mkdirp. But if they have methods like join or dirname they are used.
code update here to be compatible with both webpack4/5
// From https://github.com/ahmadnassri/mkdirp-promise/blob/master/lib/index.js
const mkdirp = function (dir, opts) {
return new Promise((resolve, reject) => {
console.log('\ndir', dir, opts, '\n');
try {
compilerFS.mkdirp(dir, opts, (err, made) => err === null ? resolve(made) : reject(err))
} catch(e) {
compilerFS.mkdir(dir, opts, (err, made) => err === null ? resolve(made) : reject(err))
}
})
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:10
Top Results From Across the Web
How to fix [prerender-spa-plugin] Unable to prerender all routes
How I fixed the prerender error with [prerender-spa-plugin], it worked yesterday but today not, just try to add a param to your webpack...
Read more >[prerender-spa-plugin] Unable to prerender all ... - Bountysource
ERROR in [prerender-spa-plugin] Unable to prerender all routes! this happened in webpack5, but work well in webpack4. node env: v12.18.2.
Read more >ERROR [prerender-spa-plugin] - Unable to prerender all routes
ok I fixed the problem by rendering less pages. It seems there is a problem with a poor connection, which in my case...
Read more >single-prerender-spa-plugin - npm package | Snyk
All security vulnerabilities belong to production dependencies of direct and indirect packages. License: MIT. Security Policy: No.
Read more >To v5 from v4 - webpack
Upgrade all used Plugins and Loaders to the latest available version ... since latest version might only support webpack 5 and will fail...
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 FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone interested, I forked the main project and created the following package which has the fix noted above for Webpack 5, along with up-to-date dependencies. Hopefully this can be PRed back into the main project repo if/when @chrisvfritz and team start supporting again.
https://www.npmjs.com/package/@dreysolano/prerender-spa-plugin
Nice find all. One caveat is that the above will not work for nested routes such as
/pages/about-us
if the/pages
dir does not already exist. The solution here is to pass{recursive: true}
in theopts
param. This solved the issue for me:compilerFS.mkdir(dir, {...opts, recursive: true}, (err, made) => err === null ? resolve(made) : reject(err))
@chrisvfritz - any chance that this project will be supported again soon? I’m sure a number of us in the community would be happy to lend a hand!