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
UnhandledPromiseRejectionWarning: Error: Multiple root routing modules found #87
Comments
Hi @keserwan, thanks for the detailed error report. The error you get comes from the https://github.com/guess-js/guess/blob/master/packages/guess-parser/src/angular/index.ts#L295 It works by analyzing the dependency tree that's formed by all the NgModules. Every NgModule which is not required by another NgModule is considered a root module. Normally there is only one NgModule which satisfies that constraint. But in your case it looks like it identified the root NgModule of all your libraries as well. Is that possible? \libs\shared\src\lib\shared-routing.module.ts
\apps\website\src\app\app.module.ts
\libs\about\src\lib\about-routing.module.ts
\libs\agent\src\lib\agent-routing.module.ts
\libs\camp\src\lib\camp-routing.module.ts
\libs\flight\src\lib\flight-routing.module.ts
\libs\game\src\lib\game-routing.module.ts
\libs\giftcard\src\lib\gift-card-routing.module.ts
\libs\home\src\lib\home-routing.module.ts
\libs\profile\src\lib\profile-routing.module.ts
\libs\trip\src\lib\trip-routing.module.ts I tried to modify the default test case to reproduce the problem. However it seems to be not enough to trigger the error. Can you tell me what else I need to do to link the Here are the commands I used: npx @angular/cli new universe --create-application=false
cd universe/
ng generate application universe --routing
ng generate universal --client-project universe
ng generate library galaxy
npm install angular-prerender --save-dev
ng build
ng run universe:server
npx angular-prerender |
I am using wrapper modules to connect the libraries with the app. { and in HomeWrapperModule.ts I am importing the lib: import { NgModule } from '@angular/core' @NgModule( |
I would assume that the |
Yes right, ur assumption is correct.
also here is libs/home/src/index.ts: Knowing that I followed best practices by Nrwl. |
Thanks a lot. I can reproduce the problem now. I think you ran into two bugs at the same time. guess-parser doesn't handle barrel files so far and it doesn't resolve local links defined as paths in the tsconfig file. I will try to submit a pull request for guess-parser later today. Once that is merged angular-prerender will hopefully work for you as well. |
Thank you @chrisguttandin |
Hi @keserwan, v4.1.20 should work now. It requires guess-parser v0.4.9 which contains the fix. But please double-check if it really works. In case it doesn't please feel free to reopen this issue. |
Thank you for your support @chrisguttandin, I am still getting the below error, after doing the following commands: here are the commands I did: here is the output: PS C:\Development\xyz\ClientApps> npx angular-prerender |
Thanks for checking it again. Sadly that error looks very familiar. It's almost the same as the one that we started with. Only the There is no chance for me to access your repo, right? The test case that I build to reproduce the error did work as expected. |
I prepared a project with the same structure on this repo |
Thanks a lot. I will take a look. |
I made a little mistake in the last pull request. I created another pull request to fix it. guess-js/guess#247 |
Thank you for your contributions! |
Hi @keserwan, can you please try it once more with v1.4.21. It does at least work with your demo project. You can also uninstall guess-parser if you don't use it for anything else. It doesn't need to be an explicit dependency as it is bundled with angular-prerender. |
Sorry for the late reply, I will check tomorrow and let you know, thank you very much for your contributions |
Hi @chrisguttandin, I updated angular-prerender to 4.1.21, deleted node-modules & package-lock.json and did the following again: npm i Note: I pushed the changes to my demo repo, https://github.com/keserwan/testAngularPrerender I am getting this error now: PS C:\Development\test\New folder> npx angular-prerender |
Hi @keserwan, I just published another patch release. Can you please try once more with version 4.1.22. Many thanks in advance. |
THANK YOU! |
I'm happy to hear that. Thanks for your patience and thanks again for making me aware of the issue in the first place. |
I am trying to do npx angular-prerender after I doing a successful ng build
I got this error:
PS C:\Development\xyz\ClientApps> npx angular-prerender
(node:1384) UnhandledPromiseRejectionWarning: Error: Multiple root routing modules found C:\Development\xyz\ClientApps\libs\shared\src\lib\shared-routing.module.ts, C:\Development\xyz\ClientApps\apps\website\src\app\app.module.ts, C:\Development\xyz\ClientApps\libs\about\src\lib\about-routing.module.ts, C:\Development\xyz\ClientApps\libs\agent\src\lib\agent-routing.module.ts, C:\Development\xyz\ClientApps\libs\camp\src\lib\camp-routing.module.ts, C:\Development\xyz\ClientApps\libs\flight\src\lib\flight-routing.module.ts, C:\Development\xyz\ClientApps\libs\game\src\lib\game-routing.module.ts, C:\Development\xyz\ClientApps\libs\giftcard\src\lib\gift-card-routing.module.ts, C:\Development\xyz\ClientApps\libs\home\src\lib\home-routing.module.ts, C:\Development\xyz\ClientApps\libs\profile\src\lib\profile-routing.module.ts, C:\Development\xyz\ClientApps\libs\trip\src\lib\trip-routing.module.ts
at findRootModule (C:\Development\xyz\ClientApps\node_modules\guess-parser\dist\guess-parser\index.js:412:15)
at exports.parseRoutes (C:\Development\xyz\ClientApps\node_modules\guess-parser\dist\guess-parser\index.js:575:31)
at prerender (C:\Development\xyz\ClientApps\node_modules\angular-prerender\build\node\functions\prerender.js:89:54)
(node:1384) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1384) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with
a non-zero exit code.
I have 3 angular apps and several libraries, but I tried to prerender the default app.
here are my configurations:
ng --version
/ △ \ | '_ \ /
| | | | |/ _
| '__| | | | | | |/ ___ | | | | (| | || | | (| | | | || | | |
// __| ||_, |_,||_,|| _|||
|___/
Angular CLI: 8.3.6
Node: 12.4.0
OS: win32 x64
Angular: 8.2.8
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker, upgrade
Package Version
@angular-devkit/architect 0.803.3
@angular-devkit/build-angular 0.803.6
@angular-devkit/build-ng-packagr 0.803.6
@angular-devkit/build-optimizer 0.803.6
@angular-devkit/build-webpack 0.803.6
@angular-devkit/core 8.3.6
@angular-devkit/schematics 8.3.6
@angular/cdk 8.2.2
@angular/cli 8.3.6
@angular/http 7.2.15
@angular/material 8.2.2
@angular/material-moment-adapter 8.2.2
@angular/pwa 0.803.6
@ngtools/webpack 8.3.6
@nguniversal/common 8.1.1
@nguniversal/express-engine 8.1.1
@nguniversal/module-map-ngfactory-loader 8.1.1
@schematics/angular 8.3.6
@schematics/update 0.803.6
ng-packagr 5.5.1
rxjs 6.5.3
typescript 3.5.3
webpack 4.39.2
The text was updated successfully, but these errors were encountered: