1

I read through existing questions but couldnt find any direction for my issue. I have a parent package, called department and under that I have english and science as packages.

I have few components in English which I have exposed using the export array in the English.module. Similarly, I have done the same for Science.module.

The issue here is,when I try to build using 'npm run build' and while Compiling TypeScript sources through ngc, it throws an error as below.

BUILD ERROR
error TS6059: File 'C:/project/package/english/english.component.ts' is notunder 'rootDir' 'C:/project/package/science/'. 'rootDir' is expected to contain all source files.

The component in science is using a component under english.

This is how my tsconfig is configured,

"baseUrl": "./package,
"rootDir": "./package

I am not sure what is missing but not able to get rid of this error. Any input will be helpful

This is my project structure

  • package
    • science
    • english

Here is my tsconfig.json

{
 "compilerOptions": {
"baseUrl": "./package",
"experimentalDecorators": true,
"target": "es5",
"moduleResolution": "node",
"rootDir": "./package",
"skipLibCheck": true,
"types": ["jasmine"]
},
"include": [
"packages/**"
]

}

CrazyMac
  • 462
  • 4
  • 19
  • Did you tried this `"rootDir": "./"?` – Bijay Yadav Feb 05 '19 at 03:53
  • Possible duplicate of [Visual Studio -> Shared TypeScript Library -> TS6059 File '' is not under 'rootDir' ''. 'rootDir' is expected to contain all source files](https://stackoverflow.com/questions/48189713/visual-studio-shared-typescript-library-ts6059-file-is-not-under-rootd) –  Feb 05 '19 at 03:55
  • @BijayYadav I did try that now but ended up with the same error. – CrazyMac Feb 05 '19 at 03:57
  • @OneLunchMan I did refer that and tried updating the rootDir in my compiler options but I dont see any difference to the error. Whether the rootDir tells the compiler the root directory to look up for files or ? – CrazyMac Feb 05 '19 at 04:02
  • @CrazyMac which answer did you try? –  Feb 05 '19 at 04:05
  • I tried referencing the ./packages/science and ./packages/english under rootDirs... Then I tried "rootDir": "../".. both didnt work for me – CrazyMac Feb 05 '19 at 04:08
  • Can you post your directory structure? And also the config files – Bijay Yadav Feb 05 '19 at 04:27
  • @BijayYadav I have added my project structure and tsconfig to my question – CrazyMac Feb 05 '19 at 04:34
  • Refer this link. StackOverflow: https://stackoverflow.com/questions/51850063/rootdir-is-expected-to-contain-all-source-files Github: https://github.com/angular/angular-cli/issues/11893 – Bijay Yadav Feb 05 '19 at 04:45
  • I referred and tried all these before I posted my question. Is there any difference in import the module or import statement for module.. Should it be something like a package being imported and not like any other files. Ex: @abc-package/ – CrazyMac Feb 05 '19 at 05:02

0 Answers0