preload-webpack-plugin icon indicating copy to clipboard operation
preload-webpack-plugin copied to clipboard

ERROR in TypeError: cb is not a function

Open awesomepeng opened this issue 6 years ago • 14 comments

preload-webpack-plugin": "^3.0.0-alpha.3 webpack": "^4.16. DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead ERROR in TypeError: cb is not a function

awesomepeng avatar Jul 15 '18 09:07 awesomepeng

I got the same error, upgrading to 3.0.0-beta.1 resolved this. Hope it helps.

timothyvanderaerden avatar Jul 16 '18 12:07 timothyvanderaerden

Unable to tap into the HtmlWebpackPlugin's callbacks. Make sure to list PreloadPlugin at some point after HtmlWebpackPlugin in webpack's plugins array.

awesomepeng avatar Jul 16 '18 13:07 awesomepeng

Is this the next error you get? If so you need to define PreloadWebpackPlugin after HtmlWebpackPlugin, as explained in the docs.

plugins: [
  new HtmlWebpackPlugin(),
  new PreloadWebpackPlugin()
]

timothyvanderaerden avatar Jul 16 '18 13:07 timothyvanderaerden

There's nothing wrong with that,but it doesn't work

awesomepeng avatar Jul 16 '18 13:07 awesomepeng

got the same error, upgrading to 3.0.0-beta.2

DENNIE-HONG avatar Nov 14 '18 09:11 DENNIE-HONG

Can you post your Webpack config and the versions of related dependencies?

timothyvanderaerden avatar Nov 14 '18 10:11 timothyvanderaerden

I'm also getting this error @timothyvanderaerden @awesomepeng.

cleanshot 2018-12-16 at 20 26 00 2x

tr1s avatar Dec 17 '18 01:12 tr1s

@tr1s It's very hard to find a solution with little information. If you, or any one else with this issue, can post the webpack configuration and package.json file, I'm sure this issue can be resolved.

timothyvanderaerden avatar Dec 17 '18 08:12 timothyvanderaerden

I'm also getting this error @timothyvanderaerden @awesomepeng.

cleanshot 2018-12-16 at 20 26 00 2x

show your code

awesomepeng avatar Dec 17 '18 12:12 awesomepeng

@timothyvanderaerden @awesomepeng I have a fully functioning webpack-boilerplate repo that I'm trying to add the preloading to. Please head over there and look at the config and/or git clone and npm install and then npm run start to get it going.

My boilerplate is working right now, but once I npm install preload-webpack-plugin, add const PreloadWebpackPlugin = require('preload-webpack-plugin'); and new PreloadWebpackPlugin() to the webpack.common.js config I get the error I posted above, and my webpage produces this image below.

screenshot 2018-12-17 11 18 06

I have tried updating all my npm packages as well as trying different options for the PreloadWebpackPlugin() but I still get the same errors.

Please let me know if you know what's wrong with all this information now, thank you.

tr1s avatar Dec 17 '18 16:12 tr1s

@tr1s I looked at your project and got it working just fine. You are using Webpack 4 but, as far as I know, the current version of preload-webpack-plugin doesn't support it yet. You should use version 3.0.0-beta.

You can install it like this: npm install [email protected] --save-dev

timothyvanderaerden avatar Dec 17 '18 18:12 timothyvanderaerden

@timothyvanderaerden thanks. The comment was so old I assumed it was out of beta by now.

tr1s avatar Dec 18 '18 16:12 tr1s

same, it is not working

p3x-robot avatar Jan 30 '20 10:01 p3x-robot

Same, is not working

am2619015 avatar Jan 03 '21 20:01 am2619015