Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Unable to prerender all routes! #437

Open
nkHub opened this issue Apr 9, 2021 · 7 comments
Open

Unable to prerender all routes! #437

nkHub opened this issue Apr 9, 2021 · 7 comments

Comments

@nkHub
Copy link

nkHub commented Apr 9, 2021

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

@nkHub
Copy link
Author

nkHub commented Apr 9, 2021

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

@evd1ser
Copy link

evd1ser commented Apr 13, 2021

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?

@zenghj
Copy link

zenghj commented Apr 28, 2021

I got the same isuue

@zenghj
Copy link

zenghj commented Apr 28, 2021

There is alreay a merge request to solve this issue here

@dmitryuk
Copy link

github:RoboFinance/prerender-spa-plugin#4.0.0

@nangezi123
Copy link

nangezi123 commented Sep 17, 2021

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
             }
        })
}),

@Tofandel
Copy link

Tofandel commented Apr 2, 2022

Duplicate of #414, not compatible with webpack 5

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants