GoogleChromeLabs / prerender-loader

📰 Painless universal pre-rendering for Webpack.
https://npm.im/prerender-loader
Apache License 2.0
1.9k stars 50 forks source link

TypeError: Cannot read property 'hash' of undefined #37

Closed mthines closed 3 years ago

mthines commented 5 years ago

Hey! Awesome project!

I've been trying to setup the prerender, but i keep getting the following error:

/Users/madsthines/Workspace/Adapt/react_boilerplate/node_modules/react-scripts/node_modules/webpack/lib/Compilation.js:2285
                        hash.update(child.hash);
                                          ^
TypeError: Cannot read property 'hash' of undefined
Show full error message

```shell /Users/madsthines/Workspace/Adapt/react_boilerplate/node_modules/react-scripts/node_modules/webpack/lib/Compilation.js:2285 hash.update(child.hash); ^ TypeError: Cannot read property 'hash' of undefined at Compilation.createHash (/Users/madsthines/Workspace/Adapt/react_boilerplate/node_modules/react-scripts/node_modules/webpack/lib/Compilation.js:2285:22) at hooks.optimizeTree.callAsync.err (/Users/madsthines/Workspace/Adapt/react_boilerplate/node_modules/react-scripts/node_modules/webpack/lib/Compilation.js:1288:9) at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/madsthines/Workspace/Adapt/react_boilerplate/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1) at AsyncSeriesHook.lazyCompileHook (/Users/madsthines/Workspace/Adapt/react_boilerplate/node_modules/tapable/lib/Hook.js:154:20) at Compilation.seal (/Users/madsthines/Workspace/Adapt/react_boilerplate/node_modules/react-scripts/node_modules/webpack/lib/Compilation.js:1244:27) at hooks.make.callAsync.err (/Users/madsthines/Workspace/Adapt/react_boilerplate/node_modules/react-scripts/node_modules/webpack/lib/Compiler.js:624:17) at _err0 (eval at create (/Users/madsthines/Workspace/Adapt/react_boilerplate/node_modules/tapable/lib/HookCodeFactory.js:33:10), :11:1) at _addModuleChain (/Users/madsthines/Workspace/Adapt/react_boilerplate/node_modules/react-scripts/node_modules/webpack/lib/Compilation.js:1095:12) at processModuleDependencies.err (/Users/madsthines/Workspace/Adapt/react_boilerplate/node_modules/react-scripts/node_modules/webpack/lib/Compilation.js:1007:9) at process._tickCallback (internal/process/next_tick.js:61:11) ```

My setup

I'm using CRA 3, Typescript and the Html Webpack Plugin. I've installed the module with Yarn, and double checked it's in the package.json and in the actually node_modules folder.

// Use the correct index.html template.
new HtmlWebpackPlugin({
  inject: false,
  template: `!!prerender-loader?string&entry=./src/index.tsx!${paths.appHtml}`,
  favicon: `${paths.appPublic}/favicons/favicon.ico`,
  manifest: `/manifest.json`,
}),

I thought I might had the same issue as issue 25, but adding the entry, didn't help me.

Any thoughts on why I get this issue?

vitaliyhayda commented 5 years ago

same issue

vitaliyhayda commented 5 years ago

After correctly specifying entry, I was able to get another error:

ERROR in   Error: Child compilation failed:
      Module build failed (from ./node_modules/prerender-loader/dist/prerender-loader.js):
      NonErrorEmittedError: (Emitted value instead of an instance of Error) TypeError: window.URL.createObjectURL is not a function
shuwenjunn commented 4 years ago

Have you fixed it

PLQin commented 4 years ago

see https://github.com/mzgoddard/hard-source-webpack-plugin/issues/416

It might solve your problem

Hypnosphi commented 4 years ago

@PLQin I tried rm -rf node_modules/.cache as suggested there, but it doesn't fix the problem

@vitaliyhayda how exactly did you fix your entry?