Angular CLI 6.0.1 doesn't generate baseUrl in tsconfig.app.json
Versions
<!--
Output from: `ng --version`.
If nothing, output from: `node --version` and `npm --version`.
Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra?)
-->
Angular CLI: 6.0.1 Node: 10.1.0 OS: win32 x64 Angular: 6.0.1 ... animations, cli, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router
Package Version
@angular-devkit/architect 0.6.1 @angular-devkit/build-angular 0.6.1 @angular-devkit/build-optimizer 0.6.1 @angular-devkit/core 0.6.1 @angular-devkit/schematics 0.6.1 @ngtools/webpack 6.0.1 @schematics/angular 0.6.1 @schematics/update 0.6.1 rxjs 6.1.0 typescript 2.7.2 webpack 4.6.0
Repro steps
- ng new SomeProject --routing
- setup routing with lazy loading modules
- ng serve
Observed behavior
<!-- Normally this includes a stack trace and some more information. -->
Failed to compile (ERROR in Could not resolve module app/users/users.module relative to ..../src/app/app-routing.module.ts)
Workaround: set "baseUrl" param to "./" value in tsconfig.app.json
Desired behavior
Angular CLI generates tsconfig.app.json with "baseUrl" value.
Mention any other details that might be useful (optional)
I'm sorry my mistake. Lazy loading path must include "src" folder:
loadChildren: 'src/app/users/users.module#UsersModule'
relative to "baseUrl" value in the root tsconfig.json
I was misled by the guide https://angular.io/guide/lazy-loading-ngmodules in which the lazy loading path is specified relative to the "src" folder (in this case "baseUrl" with "./" value should be specified in tsconfig.app.json)
Angular CLI 6 doesn't generate baseUrl of compilerOptions in tsconfig.app.json. This makes an error that can not resolve lazy loading feature modules starting with 'app/...' paths.
Which of the followings will be a recommended way to solve the error?
- Add 'baseUrl' to tsconfig.app.json
- Change paths of lazy loading feature modules to 'src/app/...' or './...'
In my opinion, we should follow the official Angular Docs with 'app/...' paths of lazy loading feature modules. Therefore, It'll be better to add 'baseUrl' to tsconfig.app.json.
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.