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.

Error when running `npm test` after `ng eject`

See original GitHub issue

Bug 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:closed
  • Created 6 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
kentonbmaxcommented, Nov 30, 2017

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.

1reaction
fr0commented, Aug 2, 2017

I just confirmed that newer versions of the cli do not have this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm run eject error? [closed] - reactjs - Stack Overflow
This error occurs after I run npm run eject in my react project. Maybe someone knows how to solve this problem (error in...
Read more >
Error after ng eject then npm start · Issue #9653 - GitHub
I have used ng eject to get the webpack.config then i used npm start but it ... i was expecting like ng serve...
Read more >
ngx-build-plus - npm
Start using ngx-build-plus in your project by running `npm i ... Extend the Angular CLI's default build behavior without ejecting:.
Read more >
Angular CLI Commands For Angular Application
To run your builds, you now need to do the following commands: - "npm run build" to build. - "npm test" to run...
Read more >
Webpack Plugin — JSDefender User Guide 2.6
To eject, run the following command: ng eject. After ejecting, add the JSDefenderWebpackPlugin to the plugins array in the webpack.config.js as shown in...
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