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

ng build Module not found: Error: Recursion in resolving #18021

Closed
1 of 15 tasks
matteobruni opened this issue Jun 25, 2020 · 9 comments · Fixed by #18009
Closed
1 of 15 tasks

ng build Module not found: Error: Recursion in resolving #18021

matteobruni opened this issue Jun 25, 2020 · 9 comments · Fixed by #18009

Comments

@matteobruni
Copy link

matteobruni commented Jun 25, 2020

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

In Angular 9.x it the command was working fine

Description

Build broken in Angular 10.x

🔬 Minimal Reproduction

Project demo/angular here https://github.com/matteobruni/tsparticles/tree/dev/demo/angular, if you run yarn build:disabled you get the error (the script has :disabled for CI)

🔥 Exception or Error


0% compiling
Compiling @angular/core : es2015 as esm2015

Compiling @angular/common : es2015 as esm2015

Compiling @angular/platform-browser : es2015 as esm2015

Compiling @angular/platform-browser-dynamic : es2015 as esm2015

ERROR in ./src/app/app.module.ts
Module not found: Error: Recursion in resolving
Stack:
  resolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/demo/angular/src/app) ng-particles/dist/ng-particles
  newResolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/demo/angular/src/app) ng-particles/dist/ng-particles
  parsedResolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/demo/angular/src/app) ng-particles/dist/ng-particles module
  describedResolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/demo/angular/src/app) ng-particles/dist/ng-particles module
  rawModule: (/Users/matteo/Projects/GitHub Projects/tsparticles/demo/angular/src/app) ng-particles/dist/ng-particles
  module: (/Users/matteo/Projects/GitHub Projects/tsparticles/demo/angular/src/app) ng-particles/dist/ng-particles
  resolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules) ./ng-particles/dist/ng-particles
  newResolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules) ./ng-particles/dist/ng-particles
  parsedResolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules) ./ng-particles/dist/ng-particles
  describedResolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules) ./ng-particles/dist/ng-particles
  relative: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules/ng-particles/dist/ng-particles) 
  describedRelative: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules/ng-particles/dist/ng-particles) 
  rawFile: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules/ng-particles/dist/ng-particles) 
  file: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules/ng-particles/dist/ng-particles) 
  relative: (/Users/matteo/Projects/GitHub Projects/tsparticles/wrappers/angular/dist/ng-particles) 
  describedRelative: (/Users/matteo/Projects/GitHub Projects/tsparticles/wrappers/angular/dist/ng-particles) 
 @ ./src/app/app.module.ts 4:0-67 12:12-29 15:8-25 24:20-37
 @ ./src/main.ts
 @ multi ./src/main.ts
ERROR in ./src/app/app.component.ts
Module not found: Error: Recursion in resolving
Stack:
  resolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/demo/angular/src/app) ng-particles/dist/ng-particles
  newResolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/demo/angular/src/app) ng-particles/dist/ng-particles
  parsedResolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/demo/angular/src/app) ng-particles/dist/ng-particles module
  describedResolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/demo/angular/src/app) ng-particles/dist/ng-particles module
  rawModule: (/Users/matteo/Projects/GitHub Projects/tsparticles/demo/angular/src/app) ng-particles/dist/ng-particles
  module: (/Users/matteo/Projects/GitHub Projects/tsparticles/demo/angular/src/app) ng-particles/dist/ng-particles
  resolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules) ./ng-particles/dist/ng-particles
  newResolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules) ./ng-particles/dist/ng-particles
  parsedResolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules) ./ng-particles/dist/ng-particles
  describedResolve: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules) ./ng-particles/dist/ng-particles
  relative: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules/ng-particles/dist/ng-particles) 
  describedRelative: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules/ng-particles/dist/ng-particles) 
  rawFile: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules/ng-particles/dist/ng-particles) 
  file: (/Users/matteo/Projects/GitHub Projects/tsparticles/node_modules/ng-particles/dist/ng-particles) 
  relative: (/Users/matteo/Projects/GitHub Projects/tsparticles/wrappers/angular/dist/ng-particles) 
  describedRelative: (/Users/matteo/Projects/GitHub Projects/tsparticles/wrappers/angular/dist/ng-particles) 
 @ ./src/app/app.component.ts 3:0-53 360:22-45
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi ./src/main.ts
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

🌍 Your Environment



     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 10.0.0
Node: 12.17.0
OS: darwin x64

Angular: 10.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: 

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.1000.0
@angular-devkit/build-angular      0.1000.0
@angular-devkit/build-ng-packagr   0.1000.0
@angular-devkit/build-optimizer    0.1000.0
@angular-devkit/build-webpack      0.1000.0
@angular-devkit/core               10.0.0
@angular-devkit/schematics         10.0.0
@ngtools/webpack                   10.0.0
@schematics/angular                10.0.0
@schematics/update                 0.1000.0
ng-packagr                         10.0.0
rxjs                               6.5.5
typescript                         3.9.5
webpack                            4.43.0

Anything else relevant?

@alan-agius4
Copy link
Collaborator

Hi @matteobruni,

I am unable to replicate the above error with the provided steps.

I encountered this following error

ERROR in src/app/app.module.ts:5:35 - error TS2307: Cannot find module 'ng-particles/dist/ng-particles' or its corresponding type declarations.

5 import { NgParticlesModule } from 'ng-particles/dist/ng-particles';

Which seems to be related to one of the imports.
https://github.com/matteobruni/tsparticles/blob/31cdc2ad3e54c70bf5710a1a250404e78f50b402/demo/angular/src/app/app.module.ts#L5

Which should be replaced with

import { NgParticlesModule } from 'ng-particles';

@alan-agius4 alan-agius4 added needs: more info Reporter must clarify the issue and removed type: bug/fix labels Jun 25, 2020
@matteobruni
Copy link
Author

matteobruni commented Jun 25, 2020

Hi @alan-agius4

Sorry I forgot some steps to be done in the root folder

yarn install && lerna bootstrap && lerna run build

This should build the library for the demo project. The path is correct with the list folder for a workaround with the lerna package management

EDIT: I don't know if the Angular wrapper has issues, the build completes without warnings. You can find it in wrappers/angular folder if you need more info

@ngbot ngbot bot modified the milestone: needsTriage Jun 25, 2020
@alan-agius4 alan-agius4 added freq1: low Only reported by a handful of users who observe it rarely type: bug/fix labels Jun 25, 2020
@slubowsky
Copy link

I get same issue updating from 9 to 10. Works fine in 9 fails in 10 with error

ERROR in ./src/app/app.module.ts
Module not found: Error: Recursion in resolving
...

Package causing problem is a local package referenced in package.json using file - https://docs.npmjs.com/files/package.json#local-paths

@ngbot ngbot bot modified the milestones: needsTriage, Backlog Jun 25, 2020
seanlandsman added a commit to ag-grid/ag-grid-angular-cli-example that referenced this issue Jun 26, 2020
seanlandsman added a commit to ag-grid/ag-grid that referenced this issue Jun 26, 2020
@michaelfaith
Copy link
Contributor

michaelfaith commented Jun 26, 2020

I'm getting the same issue after upgrading from 9 to 10 this morning. Was working like a champ with 9. Upgraded core, cli, and material, and now i'm getting blasted with these module recursion errors on app build. Library build with ng-packagr is working ok. But ng build on the app gives that for every module the app uses from the local library build.

Similar, i think, as @slubowsky. Thanks for jumping on this @alan-agius4

@alan-agius4 alan-agius4 removed the freq1: low Only reported by a handful of users who observe it rarely label Jun 26, 2020
@ngbot ngbot bot modified the milestones: Backlog, needsTriage Jun 26, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Jun 26, 2020
@SanderElias
Copy link

SanderElias commented Jun 27, 2020

This seems to be ts-lib related. When I include tsLib 1.13.0 as a dependency of my (CLI created) library) so I don't run into trouble with the tsLib 2.0.0 included in Angular v10, I get this error.
When I leave out the dependency, it compiles but fails during run-time. This seems to be a catch-22, an I hope we can find a solution for this.
Otherwise, I will have to separately build and maintain my libs for every major Angular version.

My problem was caused by using a symlink in my node_modules. Fixed by not doing that.

@javiermarinros
Copy link

Same here, problem caused by symlinking node_modules in my build process

@donmahallem
Copy link

donmahallem commented Jun 27, 2020

Hit the same issue when upgrading to Version 10. I couldn't find the source of the change between 9 and 10 as the last commit seems to be merged already in 9 in the source BUT I can confirm that symlinks where the root of the issue.

The solution for me in the meantime is settting preserveSymlinks to true in angular.json under architect->build/test->options but I don't know if there are specific sideeffects. Would be great if someone with more knowledge could leave an opinion on this.

EDIT: An alternative would be to execute ng build/test with the --preserveSymlinks true argument as one would have to add the option to every relevant architect entry afaik.

@matteobruni
Copy link
Author

Hit the same issue when upgrading to Version 10. I couldn't find the source of the change between 9 and 10 as the last commit seems to be merged already in 9 in the source BUT I can confirm that symlinks where the root of the issue.

The solution for me in the meantime is settting preserveSymlinks to true in angular.json under architect->build->options but I don't know if there are specific sideeffects. Would be great if someone with more knowledge could leave an opinion on this.

Thanks, this is the workaround I was searching. My broken angular project is a demo one so I don't care about side effects for now.

donmahallem added a commit to manniwatch/manniwatch that referenced this issue Jun 27, 2020
donmahallem added a commit to manniwatch/manniwatch that referenced this issue Jun 27, 2020
* fix(client-ng): prevent issue with symlinked modules

temporarly(?) fixes issues regarding angular/angular-cli#18021

* fix(client-ng): set preserveSymlinks true for test builds
villelahdenvuo pushed a commit to villelahdenvuo/angular-cli that referenced this issue Jul 6, 2020
@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 Jul 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants