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.

How to detect an angular component and module created with nx CLI ?

See original GitHub issue

I have used these commands :

nx g @nrwl/angular:lib test
nx g @nrwl/angular:component test --project=test --export

That gives : libs/test/src/lib/test.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TestComponent } from './test/test.component';

@NgModule({
  imports: [CommonModule],
  declarations: [TestComponent],
  exports: [TestComponent],
})
export class TestModule {}

libs/test/src/lib/test/test.component.ts

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'catalogue-ng-ui-test',
  templateUrl: './test.component.html',
  styleUrls: ['./test.component.scss']
})
export class TestComponent implements OnInit {
  constructor() { }

  ngOnInit(): void {
  }
}

libs/test/src/index.ts

export * from './lib/test.module';

tsconfig.base.json

// ...
"@catalogue-ng-ui/test": ["libs/test/src/index.ts"]
// ...

But when I want to import TestComponent in : libs/shared/util/src/lib/shared-util.module.ts, libs/shared/util/src/lib/request.util.ts or libs/shared/util/src/lib/ngb-date-moment-adapter.util.ts

import { TestComponent } from './../../../../test/src/lib/test/test.component';
// this is working : 'TestComponent' is declared but its value is never read.

// OR

import { TestComponent } from '@repo-name/test';
// 'TestComponent' is declared but its value is never read.ts(6133)
// Module '"../../../../test/src"' has no exported member 'TestComponent'.

Or in an app (named app-ui) : apps/app-ui/src/app/app.module.ts, apps/app-ui/src/app/home/home.component.ts or apps/app-ui/src/app/home/home.module.ts

import { TestComponent } from './../../../../libs/test/src/lib/test/test.component';
// this is working : 'TestComponent' is declared but its value is never read.ts(6133)


import { TestComponent } from '@repo-name/test';
// Cannot find module '@repo-name/test' or its corresponding type declarations.ts(2307)

I want to import it with the @repo-name/test path rather than a ../../../../ relative path. Or, if possible, the module itself (test.module.ts) in the app.module.ts or home.module.ts.

I’m on Manjaro i3, with VS Code

❯ nx report                                                 

>  NX  Report complete - copy this into the issue template

  nx : Not Found
  @nrwl/angular : 10.0.7
  @nrwl/cli : 10.0.7
  @nrwl/cypress : 10.0.7
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 10.0.7
  @nrwl/linter : Not Found
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 10.0.7
  @nrwl/web : Not Found
  @nrwl/workspace : 10.0.7
  typescript : 3.9.7

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
E-jarodcommented, Sep 15, 2020

@bekos okay thanks 👍

0reactions
bekoscommented, Sep 15, 2020

@E-jarod Not sure I can help with that 😃 What you describe here is a heavily used feature, and would be very surprised if it was broken! Try to debug by replicating the steps in your project and you will probably find it out 🤞

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 - Generating components and Nx lib - Angular and NgRx
3 - Generating components and Nx lib · Run the below command to see all the lib options · Add a new lib...
Read more >
@nrwl/angular:component | Nx
Specifies if the component should be exported in the declaring NgModule . Additionally, if the project is a library, the component will be...
Read more >
Tutorial - First Steps with Nx and Angular Architecture
This tutorial shows how to get started with Nx. It starts from scratch with an empty Nx workspace. You learn the following things:....
Read more >
nx/cli - angular - Generate pages - Specified module ... - GitHub
I'm unable to generate pages in my angular app. Expected Behavior. nx g module page --module app --route page --project demo.
Read more >
Generating Standalone Component-based Angular ... - Nx Blog
Angular recently released Standalone Components in an effort to ... First, create a new Nx Workspace by running the following command:
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