question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: The 'compilation' argument must be an instance of Compilation

See original GitHub issue

Bug report

What is the current behavior? After the migration of webpack v4.41.6 to v5.37.0 our build fail with to following stack strace:

An error occurred during the build:
TypeError: The 'compilation' argument must be an instance of Compilation
    at Function.getCompilationHooks (/home/runner/work/theGardener/theGardener/frontend/node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js:125:10)
    at /home/runner/work/theGardener/theGardener/frontend/node_modules/terser-webpack-plugin/dist/index.js:566:67
    at _next43 (eval at create (/home/runner/work/theGardener/theGardener/frontend/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:40:1)
    at _next21 (eval at create (/home/runner/work/theGardener/theGardener/frontend/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:97:1)
    at Hook.eval [as call] (eval at create (/home/runner/work/theGardener/theGardener/frontend/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:143:1)
    at Hook.CALL_DELEGATE [as _call] (/home/runner/work/theGardener/theGardener/frontend/node_modules/tapable/lib/Hook.js:14:14)
    at Compiler.newCompilation (/home/runner/work/theGardener/theGardener/frontend/node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/Compiler.js:1031:26)
    at /home/runner/work/theGardener/theGardener/frontend/node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/Compiler.js:1073:29
    at Hook.eval [as callAsync] (eval at create (/home/runner/work/theGardener/theGardener/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/runner/work/theGardener/theGardener/frontend/node_modules/tapable/lib/Hook.js:18:14)
    at Compiler.compile (/home/runner/work/theGardener/theGardener/frontend/node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/Compiler.js:1068:28)
    at /home/runner/work/theGardener/theGardener/frontend/node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/Compiler.js:496:12
    at Compiler.readRecords (/home/runner/work/theGardener/theGardener/frontend/node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/Compiler.js:908:11)
    at /home/runner/work/theGardener/theGardener/frontend/node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/Compiler.js:493:11
    at Hook.eval [as callAsync] (eval at create (/home/runner/work/theGardener/theGardener/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/runner/work/theGardener/theGardener/frontend/node_modules/tapable/lib/Hook.js:18:14)
An unhandled exception occurred: The 'compilation' argument must be an instance of Compilation

If the current behavior is a bug, please provide the steps to reproduce.

Github repository: https://github.com/KelkooGroup/theGardener/blob/feature/update-angular-12/frontend/package.json Failing Github CI build: https://github.com/KelkooGroup/theGardener/runs/2576502917

What is the expected behavior?

ng build should not fail with the TypeError: The 'compilation' argument must be an instance of Compilation error with webpack 5.

Other relevant information: webpack version: 5.37.0 Node.js version: 14.16.1 Operating System: Alpine Additional tools: Github Actions

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
notfloriancommented, May 13, 2021

Thanks it works.

Indeed this was a bug in angular CLI with webpack 5.37.0, fixed by this commit: https://github.com/angular/angular-cli/pull/20735/commits/56b348db311dbdc83cfa2e678f3758e888073671

1reaction
alexander-akaitcommented, May 13, 2021

Try to remove own webpack (i.e. remove it from package.json) and run build again

Read more comments on GitHub >

github_iconTop Results From Across the Web

The 'compilation' argument must be an instance of Compilation
The command I'm running is ng build . My angular.json is as follows: { "$schema": "./node_modules/@angular/cli/ ...
Read more >
Webpack 5: The 'compilation' argument must be an instance of ...
TypeError: The 'compilation ' argument must be an instance of Compilation - JavascriptModulesPlugin.js:116 Function.
Read more >
[webpack-cli] TypeError: The 'compilation' argument must be ...
When i run npm run dev i get this error: Copy Code [webpack-cli] TypeError: The 'compilation' argument must be an instance of Compilation....
Read more >
Fixing the "'compilation' argument must be an instance of ...
The fix is simply to get all of your packages to use the same webpack version. To see what your project is using,...
Read more >
Webpack v5 Upgrade - `start-storybook` works but ... - Issuehunt
The majority of the times that I've had erratic TypeError: The 'compilation' argument must be an instance of Compilation errors, it has been...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found