I generated a new library in a new workspace and tried to import it into my app.
I get the above linting error when trying to import the lib into an app
import { MaterialModule } from '@myproject/material/src/material.module';
Any ideas what Im doing wrong
What is reason, how it shall be in correct way? I have same problem, and in nx-example is the same problem
Still getting this issue with the following line:
import { DatabaseService } from '@my-products/database/src/database.service';
Any ideas?
As _always_ happens when I ask people questions, I found the answer myself. I just added
export * from './src/database.service';
to my index.ts of the lib. and updated the import:
import { DatabaseService } from '@my-products/database;
@jdk339 I'm finding my linter still complaining about import of apps are forbidden following your advice. I also updated the angular.json file and set the projectType to library but to no avail. Any thoughts?
@here - Here is a brief explanation:
This issue happens when you are using (aka importing) an external library into some source module and the import path by-passes the barrel (index.ts); by using /src/ or /src/lib/ as part of the import path.
The goal of the barrel is to define the public API of the library. Anything else is non-public, considered private/hidden and should NOT be directly accessed.
For libraries with source that wants to import files from inside the same lib, you should always use relative path imports.
Consider this:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { ticketsStateModelReducer } from './+state/tickets-state-model.reducer';
import { ticketsStateModelInitialState } from './+state/tickets-state-model.selectors';
import { TicketsStateModelEffects } from './+state/tickets-state-model.effects';
@NgModule({
imports: [
CommonModule,
StoreModule.forFeature('ticketsStateModel', ticketsStateModelReducer, {
initialState: ticketsStateModelInitialState
}),
EffectsModule.forFeature([TicketsStateModelEffects])
],
providers: [TicketsStateModelEffects]
})
export class TicketsStateModule {}
Here we have two types of imports:
@ngrx/effects is used to import EffectsModule./+state/tickets-state-model.effects to load the nests TicketsStateModelEffects.Additionally, while
TicketsStateModuleis exported as part of the public api for this library, theTicketsStateModelEffectsis not made public and is considered a private internal module.
@aire-con-gas -

Most helpful comment
@aire-con-gas -