Hard to debug TypeError: arguments[i].apply is not a function

Packages version:

  • webpack: 1.12.14
  • tapable: 0.1.10

While editing webpack config file we met the following error:


TypeError: arguments[i].apply is not a function
    at Compiler.apply (<<PROJECT_PATH>>\node_modules\tapable\lib\Tapable.js:164:16)

and that seemed a situation similar to issue #697 .

We were able to spot the offending change after some time, but still the message was not at all helpful. In our case, error was due to the following:

config.plugins = [
  // some plugins added here ...

// further down

  // another plugin here, but mistakenly added as a whole array

The fix was of course to properly add the new plugin as a single item:

  // another plugin here, correctly added as a single item

Request: try to improve argument checking or anyway improve error messages.

Thanks for your time spent on this great project!

Author: Fantashit

2 thoughts on “Hard to debug TypeError: arguments[i].apply is not a function

  1. This also happened in my case with webpack 2.2.0 when returning [Plugin, Plugin, false, Plugin] for the plugins list (I am using flag && new webpack... for adding plugins conditionally).

    Adding .filter(Boolean) at the end of the array to send an array like [Plugin] effectively solved the issue.

Comments are closed.