Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lerna with Angular: Angular Compiler was detected but it was an instance of the wrong class #13529

Closed
wizardnet972 opened this issue Jan 27, 2019 · 2 comments

Comments

@wizardnet972
Copy link

When I build my application, I got this error.

$ ng build

Date: 2019-01-27T14:25:18.561Z
Hash: 45f3fd6ac090c98d3d19
Time: 6675ms
chunk {main} main.js, main.js.map (main) 1.05 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 99.4 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.7 kB [initial] [rendered]

ERROR in ./src/main.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: Angular Compiler 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 (C:\coder2\lerna-angular\apps\ng-app\node_modules\@ngtools\webpack\src\loader.js:33:15)
ERROR in ./src/polyfills.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: Angular Compiler 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 (C:\coder2\lerna-angular\apps\ng-app\node_modules\@ngtools\webpack\src\loader.js:33:15)

I need to use lerna (not nx or bazel) with angular.

This is not lerna problem, it's happend during the build time. Lerna just link the package to node_module.

You can clone my repo and see yourself the problem.

$ npm i lerna -g
$ npm run bootstrap
$ cd apps/ng-app
$ ng build
Angular CLI: 7.2.3                                                
Node: 10.12.0                                                     
OS: win32 x64                                                     
Angular: <error>                                                  
... animations, cli, common, compiler, compiler-cli, core, forms  
... language-service, platform-browser, platform-browser-dynamic  
... router                                                        
                                                                  
Package                           Version                         
-----------------------------------------------------------       
@angular-devkit/architect         0.12.3                          
@angular-devkit/build-angular     <error>                         
@angular-devkit/build-optimizer   0.12.3                          
@angular-devkit/build-webpack     0.12.3                          
@angular-devkit/core              7.2.3                           
@angular-devkit/schematics        7.2.3                           
@ngtools/webpack                  7.2.3                           
@schematics/angular               7.2.3                           
@schematics/update                0.12.3                          
rxjs                              <error>                         
typescript                        <error>                         
webpack                           4.28.4                          
                                                                  
@alan-agius4
Copy link
Collaborator

alan-agius4 commented Jan 27, 2019

I am going to close this as a duplicate of #7097 as this is not something we support yet.

I’d suggest you post the reproduction in the linked issue.

Thank you.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants