0

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'.

1 Answer 1

1

You can use a file. You just have a typo. It should be:

"@scope/name": ["projects/test/src/public-api.ts"]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.