prerender-spa-plugin icon indicating copy to clipboard operation
prerender-spa-plugin copied to clipboard

Unable to prerender all routes!

Open nkHub opened this issue 3 years ago • 7 comments

es6/index.js in webpack5 compilerFS.mkdirp is undefined.

nkHub avatar Apr 09 '21 09:04 nkHub

I install mkdirp package and change index.js the directory of es6 for replace the function mkdirp,after that it works.

nkHub avatar Apr 09 '21 10:04 nkHub

I install mkdirp package and change index.js the directory of es6 for replace the function mkdirp,after that it works.

Same problem, could you please write more details about the solution?

evd1ser avatar Apr 13 '21 09:04 evd1ser

I got the same isuue

zenghj avatar Apr 28 '21 02:04 zenghj

There is alreay a merge request to solve this issue here

zenghj avatar Apr 28 '21 02:04 zenghj

github:RoboFinance/prerender-spa-plugin#4.0.0

dmitryuk avatar May 28 '21 08:05 dmitryuk

If no network,you must make sure that there is chromium (/node_modules/puppteer/.local-chromium)

Next, you can add console.log('err', err) in catch (/node_modules/prerender-spa-plugin/es6/index.js),you will find details.

// node_modules/prerender-spa-plugin/es6/index.js
...
.catch(err => {
        console.log('err', err) // Add this to find the error at line 144
        PrerendererInstance.destroy()
        const msg = '[prerender-spa-plugin] Unable to prerender all routes!'
        console.error(msg)
        compilation.errors.push(new Error(msg))
        done()
      })

If your error is Navigation Timeout Exceeded: 30000ms exceeded, the following need to be modified:

// node_modules/@prerenderer/renderer-puppeteer/es6/renderer.js
const navigationOptions = (options.navigationOptions) ? { waituntil: 'networkidle0', ...options.navigationOptions } : { waituntil: 'networkidle0' };

await page.goto(`${baseURL}${route}`, navigationOptions);

modify to

await page.goto(`${baseURL}${route}`, {...navigationOptions, timeout: 0});

https://stackoverflow.com/questions/52163547/node-js-puppeteer-how-to-set-navigation-timeout

In webpack, add navigationOptions: { timeout: 0} const PrerenderSpaPlugin = require("prerender-spa-plugin"); const Renderer = PrerenderSpaPlugin.PuppeteerRenderer

new PrerenderSpaPlugin({
        routes: ['/', '/contact'],
        renderer: new Renderer({
             navigationOptions: {
                 timeout: 0
             }
        })
}),

nangezi123 avatar Sep 17 '21 12:09 nangezi123

Duplicate of https://github.com/chrisvfritz/prerender-spa-plugin/issues/414, not compatible with webpack 5

Tofandel avatar Apr 02 '22 21:04 Tofandel