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.

Angular component is not a know element when importing its module

See original GitHub issue

Describe the bug In v6.2.0-alpha.28 when importing the module of a component inside a story the component is not a known element anymore.

To Reproduce

Import the module that hosts the component:

export default {
  title:      'Components/MyComponent',
  component:  MyComponent,
  decorators: [
    moduleMetadata({
      imports: [BrowserAnimationsModule, MyModule],
    }),
  ],
} as Meta;

const Template: Story<MyComponent> = (args) => ({
  component: MyComponent,
  props:     args,
});

export const MyState = Template.bind({});

In contrast it works when:

  • Removing the Module import, but thats not an option since the module imports important dependencies like pipes, services, etc.
  • Adding the component to exports, but actually I dont want to the component to be exported in my app
  • Downgrading to ^6.1.18

Expected behavior The component should be created as in 6.1.x without having to add it to module’s exports

System

System: OS: macOS 11.2.1 CPU: (12) x64 Intel® Core™ i7-9750H CPU @ 2.60GHz Binaries: Node: 15.6.0 - ~/.nvm/versions/node/v15.6.0/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.4.0 - ~/.nvm/versions/node/v15.6.0/bin/npm Browsers: Chrome: 88.0.4324.150 Firefox: 81.0.1 Safari: 14.0.3 npmPackages: @storybook/addon-actions: v6.2.0-alpha.28 => 6.2.0-alpha.28 @storybook/addon-essentials: v6.2.0-alpha.28 => 6.2.0-alpha.28 @storybook/addon-links: v6.2.0-alpha.28 => 6.2.0-alpha.28 @storybook/angular: v6.2.0-alpha.28 => 6.2.0-alpha.28

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
ThibaudAVcommented, Feb 19, 2021

Yes you are right @MickL This was a fallacious storybook behaviour and which went against the functioning of Angular. I think

either you use a module that exports the component or either you reproduce in story, the module by declaring components, imports, ext…

A mix of the 2 is incoherent. Storybook needs to make a module and Angular prohibits declaration of component in 2 different modules 😕

1reaction
eluchsingercommented, Oct 11, 2021

either you use a module that exports the component or either you reproduce in story, the module by declaring components, imports, ext…

If I try to reproduce the module by declaring components, imports, etc., I get an error that the component is defined in two modules. So the only way around this issue is to export all the components I want to have in Storybook.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 2 'component' is not a known element - Stack Overflow
1. Your folder structure isn't simple. · 1. I had this issue and solved it by including a component where it was not...
Read more >
NG8001: Unknown HTML element or component - Angular
One or more elements cannot be resolved during compilation because the element is not defined by the HTML spec, or there is no...
Read more >
Custom component: is not a known element: - Ionic Framework
I have find the solution: simply, i have include Component directly in mi custom-page.module.ts. import { NgModule } from '@angular/core'; ...
Read more >
Angular Error NG8001: is not a known element ... - YouTube
... 'mat-progress-spinner' is not a known element : Angular Error is an Angular component, then verify that it is part of this module....
Read more >
Angular 2 DoubleNavbarModule not working?
Also just a not that the SideBar module is imported by the AppModule which isn't ... is an Angular component, then verify 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