Error when running `npm test` after `ng eject`
See original GitHub issueBug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.3.0-rc.2 (e)
node: 6.10.2
os: darwin x64
@angular/common: 4.3.1
@angular/compiler: 4.3.1
@angular/core: 4.3.1
@angular/forms: 4.3.1
@angular/http: 4.3.1
@angular/platform-browser: 4.3.1
@angular/platform-browser-dynamic: 4.3.1
@angular/router: 4.3.1
@angular/cli: 1.3.0-rc.2
@angular/compiler-cli: 4.3.1
@ngtools/webpack: 1.6.0-rc.2
Repro steps.
ng eject
npm install
npm test
The log given by the failure.
ERROR in ./src/test.ts
Module build failed: Error: AotPlugin was detected but it was an instance of the wrong class.
This likely means you have several @ngtools/webpack packages installed. You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies.
at Object.ngcLoader (/.../node_modules/@ngtools/webpack/src/loader.js:430:19)
Desired functionality.
Mention any other details that might be useful.
The output of npm ls @ngtools/webpack is:
myapp@1.0.0 ├─┬ @angular/cli@1.3.0-rc.2 │ └── @ngtools/webpack@1.6.0-rc.2 └── @ngtools/webpack@1.6.0-rc.2
The workaround is to manually delete @angular/cli’s copy of @ngtools/webpack (e.g. rm -rf node_modules/@angular/cli/node_modules/@ngtools/webpack), which works because the version it needs is the same as the version my package.json is requesting. This is not a desirable long-term workaround, however.
Another possible workaround is to remove @ngtools/webpack from my package.json, as described here: https://stackoverflow.com/questions/45409582/error-aotplugin-was-detected-but-it-was-an-instance-of-the-wrong-class
However, if this is the intended way to solve the problem, I find it odd that ng eject puts @ngtools/webpack in my devDependencies to begin with.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (2 by maintainers)

Top Related StackOverflow Question
I have this issue on @angular/cli 1.5.5. Tried updating to latest webpack and targeting TS 2.4.2 still getting the Error.
I just confirmed that newer versions of the cli do not have this issue.