Arun Malik
1 min readFeb 22, 2020

Me and my friend were experimenting with Angular and monorepo and we got stuck in a situation where we wanted to use our projects library(lib2) in library(lib1)

On running “ng build lib1” All we got is this…

error TS6059: File ‘/Users/admin/Desktop/App/libs/lib2/src/util.ts’ is not under ‘rootDir’ ‘/Users/admin/Desktop/App/libs/lib1/src’. ‘rootDir’ is expected to contain all source files

Folder Structure

App

- → apps

- — — → app1

- → libs

- — — → lib1

- — — — — → src

- — — — — — — → index.ts

- — — — — → ng-package.json

- — — → lib2

Solution-

Create a new file say wrapper_index.ts in libs directory(which contains lib1 and lib2) with one line

import ‘./lib1/src/index.ts’

and also update ng-package.json in lib1 directory with

Change

“entryFile”: ‘src/index.ts’

TO

“entryFile”: ‘../wrapper_index.ts’

Now while building lib1 compiler will treat libs directory as rootDir(as entryFile wrapper_index.ts is in it) which contains both lib1 and lib2. Problem Solved ;)

New Folder Structure

App

- → apps

- — — → app1

- → libs

- — — → lib1

- — — — — → src

- — — — — — — → index.ts

- — — — — → ng-package.json

- — — → lib2

- — — → wrapper_index.ts