Angular 10: Unable to write a reference

I'm building a library and an app in the same project. My problem came when a interface definition was auto imported. The path referenced was a public api file instead of the library.

The auto imported created: import { AbcInterface } from 'projects/mylib/src/public-api'

Needed to be import { AbcInterface } from '@mylib'

So do a global search in your application for 'projects/ and change your references.


After spending 20mn looking for a similar error... I just realised that the actual error is just a linting one!

I'm using NX and therefore I'm importing many of my libs by using custom TS paths like @my-workspace/my-lib.

While developing the feature I did not realise that my IDE imported a file from another library with a relative path (instead of the custom TS path with @).

Therefore, the file I was trying to import was technically out of the rootDir (in tsconfig).

All I had to do was (run my linting and realise it was failing miserably) + replace all my relative imports of other libraries into absolute imports using the custom TS path.

EDIT: This just happened to me again and for a different reason! So sharing that new one as well.

I have a library that I've decided to split in sub entries so that they can be tree shaken. That said, the name of the library defined in my package.json (of the library, not the top level one) was the wrong one. Make sure it does match what you're trying to import.

EDIT: I can confirm that once again I got bitten by this and somehow still managed to loose 1h because of the wrong name in the lib package.json and the obscure error...