storybookjs/storybook

[Bug]: RouterModule.forRoot() is imported twice when loading a story

Open

#25,726 opened on Jan 23, 2024

View on GitHub
 (3 comments) (2 reactions) (0 assignees)TypeScript (10,058 forks)batch import
angularbughelp wanted

Repository metrics

Stars
 (89,909 stars)
PR merge metrics
 (Avg merge 7d 22h) (184 merged PRs in 30d)

Description

Describe the bug

When importing the RouterModule and using the forRoot() pattern for routing storybook seems to import this twice causing NG04007: The Router was provided more than once.

You can see this in the screenshot below: image

I see this error in: storybook 7.4.3 Angular 15 storybook 7.5 Angular 16. I even upgraded to 7.6.10 with Angular 15 and still had the same issue.

I do not have this error in storybook 7.4.3 Angular 14.

To Reproduce

Stackblitz: https://stackblitz.com/edit/github-vrpkro-pu8ckn?file=src%2Fstories%2FPage.stories.ts

Code change on line 22 in Page.Stories.ts Reproduction:

  1. Load project
  2. Navigate to page example
  3. The error will appear in place of story

You can navigate to the other examples and see that without the RouterModule.forRoot() imported you will not have the same issue.

System

Local project: 7.4.3
StackBlitz: 7.5.0-alpha
chrome: Version 120.0.6099.234

Additional context

I found a similar issue that has been resolved here: https://github.com/storybookjs/storybook/issues/21284

Contributor guide