'Cannot find module' error on imports after Angular 9 migration Follow
Hello,
got a problem with importing components after migration from Angular 8 to Angular 9.
WebStorm underlines imports path and shows error 'Cannot find module' when path is derived from root (e.g. app/src/components/comp.component) or when aliases (@shared/comp.component) are in use. It shows everything is fine when use ../../comp.component path.
What is more, app is compiling fine.
I've already enabled angular.enableIvyMetadataSupport but it changed nothing in this case.
I suppose there's a problem with ts configuration.
My tsconfig.json (in root folder):
{
"compileOnSave": false,
"compilerOptions": {
"skipLibCheck": false,
"downlevelIteration": true,
"module": "esnext",
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2015",
"paths": {
"@store/*": ["app/store/*"],
"@shared/*": ["app/shared/*"],
"@core/*": ["app/core/*"],
"@assets/*": ["../assets/*"]
},
"typeRoots": ["node_modules/@types"],
"lib": ["es2016", "dom"],
"types": ["node", "jest"]
},
"include": ["./node_modules/@types/jest", "./src/main.ts", "./src/polyfills.ts", "./src/main.server.ts", "./src"],
"no-import-side-effect": [true,
{"ignore-module": "(core-js/.*|zone\\.js/.*|@angular/localize/init)$"}
]
}
What's wrong?
Please sign in to leave a comment.
Must be a problem with your other tsconfig.*.json files; in case of multiple configs, the Typescript service uses the nearest config current file is included in, scanning folders from the file folder up to the project root. If this config doesn't have path mappings defined, or has a wrong "baseUrl", for example, you will see errors
I reviewed all ts config files and...you're obviously right - I can't believe I missed that! Thanks for help ; )
See my fix in this comment https://github.com/microsoft/TypeScript/issues/39411#issuecomment-674588408