GeezerVison is showing github.com — angular-devkit/schematics: Tree.read() returns null when tsconfig.json contains path mappings · Issue #20118 · angular/angular-cli
angular-devkit/schematics: Tree.read() returns null when tsconfig.json contains path mappings #20118DescriptionI getvthe following error in my application (with about 10 modules). To isolate the root cause I created a minimal angular app that shows the effect.
Reproduction
Use StackBlitz to reproduce your issue: https://stackblitz.com/fork/components-issue
Steps to reproduce:
- generate new angular project
ng new test-app --defaults=true --routing=false --style=scss
- add
paths to tsconfig.json
:
"lib": [
"es2018",
"dom"
],
"paths": {
"@lib/*": ["hacks/private-libs/*"],
"@app/*": ["app/*"],
"@env/*": ["environments/*"],
"@config/*": ["app/config/*"],
"@shared/*": ["app/shared/*"]
}
:
- modify
main.ts to use paths defined in tsconfig.json
:
import { AppModule } from '@app/app.module';
import { environment } from '@env/environment';
:
- add @angular/material using
ng add @angular/material
Expected Behavior
ng add @angular/material resolves import paths using paths definition in tsconfig.json
Actual Behavior
error:
Installing packages for tooling via npm.
Installed packages for tooling via npm.
? Choose a prebuilt theme name, or "custom" for a custom theme: Indigo/Pink [ Preview: https://material.angular.i
o?theme=indigo-pink ]
? Set up global Angular Material typography styles? Yes
? Set up browser animations for Angular Material? Yes
UPDATE package.json (1343 bytes)
√ Packages installed successfully.
Could not read Angular module file: /src/@app/app.module.ts
Environment
- Angular: tried V9.1 and V10
- CDK/Material:
- Browser(s): --
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 10
Reacted by Maxime Ailloud Activitymaxailloud commented on Nov 20, 2020 I got the same error.
Is there a little workaround in the meantime? At least to be able to install the package properly and not having to finish it manually. Splaktar commented on Feb 22, 2021 These reproduction steps didn't work for me in a ng new project. I had to use the following:
"paths": {
"@lib/*": ["hacks/private-libs/*"],
"@app/*": ["src/app/*"],
"@env/*": ["src/environments/*"],
"@config/*": ["src/app/config/*"],
"@shared/*": ["src/app/shared/*"]
}
However, this issue is reproducible:
$ ng add @angular/material
ℹ Using package manager: npm
✔ Found compatible package version: @angular/material@11.2.1.
✔ Package information loaded.
✔ Package successfully installed.
? Choose a prebuilt theme name, or "custom" for a custom theme: Indigo/Pink [ Preview: https://material.angular.io?theme=indigo-pink ]
? Set up global Angular Material typography styles? Yes
? Set up browser animations for Angular Material? Yes
UPDATE package.json (1264 bytes)
✔ Packages installed successfully.
Could not read Angular module file: /src/@app/app.module.ts Splaktar commented on Feb 22, 2021 changed the title [-]bug(ng add @angular/material): Could not read Angular module file with path in tsconfig.json[/-] [+]angular-devkit/schematics: Tree.read() returns null when tsconfig.json contains path mappings[/+] on Feb 22, 2021alan-agius4 commented on Feb 22, 2021 angular-automatic-lock-bot commented on Mar 25, 2021 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.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|