Reputation: 6884
I have an angular cli project, and created a new library:
ng g library test
Now, in the tsconfig.json
file, I added the following paths
options:
{
"compileOnSave": false,
"compilerOptions": {
"resolveJsonModule": true,
"esModuleInterop": true,
"baseUrl": ".",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "dom"],
"paths": {
"@scope/name": ["projects/test/src/public_api.ts"]
}
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
But now when I try to use it in the application:
import { SomeComponent } from '@scope/name';
@NgModule({
...
})
export class AppModule {}
I get the error:
error TS2307: Cannot find module '@scope/name'.
Upvotes: 0
Views: 255
Reputation: 11244
You can use a file. You just have a typo. It should be:
"@scope/name": ["projects/test/src/public-api.ts"]
Upvotes: 1