Cannot find module or its corresponding type declarations when using my own library

3.1k views Asked by At

I created a workspace with applications and my first library which was created with the command ng g library breeze-helpers (breeze-helpers is the name of my library)

Then I built the library with ng build breeze-helpers --watch. It is successfully compiled to the dist folder of my workspace.

In the main tsconfig file the following was added automatically:

"paths": {     
      "breeze-helpers": [
        "dist/breeze-helpers/breeze-helpers",
        "dist/breeze-helpers"
      ]
    }

I then imported the library in one of my applications :

import { BreezeHelpersModule } from 'breeze-helpers';

@NgModule({
  declarations: [
    AppComponent,
 
  ],
  imports: [
    BreezeHelpersModule
  ],

and I can use it in my code :

import { EntityManagerService } from 'breeze-helpers';

Visual Studio Code provides me with intellisense and no errors is found. However when I build my application with ng build my-app I get plenty of errors :

enter image description here

I can't figure out what I'm missing. I've been following this documentation.

1

There are 1 answers

0
Sam On BEST ANSWER

Found the problem. I had to create a simlink as explained here

$ cd ./dist/my-lib
$ npm link

$ cd my-app
$ npm link my-lib