[prerender-spa-plugin] Unable to prerender all routes! when upgrade webpack to v5+
ERROR 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))
}
})
}Source: chrisvfritz/prerender-spa-plugin