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.

[Ivy - 9.0.0-rc.1] Running `ngc` on a custom library throws error "Appears in the NgModule.imports of ..., but could not be resolved to an NgModule class"

See original GitHub issue

🐞 bug report

Affected Package

@angular/common but I expect that others can also have this issue.

Is this a regression?

Yes, running ngc on a code of a library that uses Angular’s packages has always works and the correct .metadata.json files have been created.

Description

Running ngc to generate the metadata.json of my custom library’s source code fails when using the latest 9.0.0.x release, currently available in the @next tag at npm.

I am testing how to building my package will work when 9.0.0 comes out.

πŸ”¬ Minimal Reproduction

As this requires compiling with ngc I have prepared a very simply package and you can download it here ngc issue.zip

Simply do the following:

  • Extract the archive and open it in a terminal
  • Install the npm packages with npm install
  • Trigger ngc by executing ./node_modules/.bin/ngc

The following error is thrown:

πŸ”₯ Exception or Error



node_modules/@angular/common/common.d.ts:115:22 - error NG6002: Appears in the NgModule.imports of MyCommonModule, but could not be resolved to an NgModule class

115 export declare class CommonModule {
                         ~~~~~~~~~~~~
node_modules/@angular/common/common.d.ts:115:22 - error NG6003: Appears in the NgModule.exports of MyCommonModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class

115 export declare class CommonModule {
                         ~~~~~~~~~~~~

🌍 Your Environment

Angular Version:



Angular CLI: 9.0.0-rc.1
Node: 10.15.2
OS: darwin x64
Angular: 9.0.0-rc.1
... common, compiler, compiler-cli, core

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.900.0-rc.1 (cli-only)
@angular-devkit/core         9.0.0-rc.1 (cli-only)
@angular-devkit/schematics   9.0.0-rc.1 (cli-only)
@schematics/angular          9.0.0-rc.1 (cli-only)
@schematics/update           0.900.0-rc.1 (cli-only)
rxjs                         6.5.3
typescript                   3.6.4

Anything else relevant? I am hitting this error in preparation for Ivy and 9.0.0 of my custom Angular library. I would love some assistance before 9.0.0 is live because at the moment I cannot build my custom library when using Angular packages 9.0.0

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
alexzuzacommented, Nov 8, 2019

@VladimirAmiorkov Ivy compiler is default compiler since 9.0.0-next.3(https://github.com/angular/angular/blob/master/CHANGELOG.md#breaking-changes-8). If you want to compile your library in ViewEngine mode then I would suggest you using enableIvy option in your tsconfig.json

"angularCompilerOptions": {
      "genDir": ".",
      "skipMetadataEmit": false,
      "skipTemplateCodegen": true,
      "strictMetadataEmit": true,
      "enableIvy": false   <------------------ try this
    },
0reactions
angular-automatic-lock-bot[bot]commented, Dec 9, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Appears in the NgModule.imports of AppModule, but could not ...
It seems to be a problem with Ivy, from my research. I don't have a lot of experience modifying tsconfig.app.json, which is the...
Read more >
Answer: error NG6002: Appears in the NgModule.imports of ...
imports of AppModule, but could not be resolved to an NgModule class. Feb 18 '20. 3. Fixed it by opting out of Ivy...
Read more >
Containers For Deep Learning Frameworks User Guide
This guide provides a detailed overview about containers and step-by-step instructions for pulling and running a container and customizing and extendingΒ ...
Read more >
angular/angular-cli - Gitter
Q: I am attempting to write component tests, started from the angular cli. My components are using ES6 imports to pull in the...
Read more >
ngx-toastr - Bountysource
ts:4:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class. This likely means that...
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