Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NRWL NX importing lib error TS2307: Cannot find module '@eduboard/interfaces'

I've just created a new NX project for work and I've created a lib for out interfaces to have them on the backend and the front end.

I'm getting this error when I compile

apps/askeddi/src/app/pages/global-admin/global-admin.component.ts(5,38): error TS2307: Cannot find module '@eduboard/interfaces'.

From everything i have read is that i have done nothing wrong but its asking for a module and its just an index.ts file.

export * from './lib/user';
export * from './lib/global-admin-dashboard';

And this the global-admin-dashboard

interface Schools {
  total: number;
  active: number;
  usingAssessor: number;
}

interface TotalNActive {
  total: number;
  active: number;
}

export interface GlobalAdminDashboard {
  schools: Schools;
  schoolGroups: TotalNActive;
  users: TotalNActive;
}

like image 979
Skel Avatar asked Dec 01 '25 23:12

Skel


2 Answers

I found out how to fix my problem.

So inside the tsconfig.app.json file, I added this to the paths.

"@eduboard/interfaces" : [
  "../../../libs/interfaces/src/index"
  ]

I had to go back a fair few because I had it have a baseURL set to src/

like image 149
Skel Avatar answered Dec 04 '25 19:12

Skel


You need to specify the location of your library for TypeScript to locate.

Add your library to the tsconfig.json at the root of your project under "paths":

{
  "compilerOptions": {
    ...
    "paths": {
      "@package/my-lib": ["libs/my-lib/src/index.ts"]
    }
  }
}

You may need to reload VSCode to have TypeScript reload the tsconfig.json.

like image 40
Ari Seyhun Avatar answered Dec 04 '25 18:12

Ari Seyhun