'rootDir' is expected to contain all source files

See original GitHub issue

I am facing issue with ngx-uploader. when I run tsc, it’s working fine. but when I run npm start it is giving me below error error TS6059: File ‘node_modules/ngx-uploader/src/classes/index.ts’ is not under ‘rootDir’ ‘xxx/src’. ‘rootDir’ is expected to contain all source files.

tsconfig.json

  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "rootDir": "src/",    
    "outDir": "build",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  },
    "exclude": [
        "node_modules",
        "**/*.spec.ts",
        "bower_components",
        "build"
    ]
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

55reactions
forsignercommented, Aug 16, 2018

should exclude all source filesin tsconfig.json,example:

{
  "exclude": ["node_modules", "lib", "tests"]
}

here /tests contain ts source files. see: https://github.com/Microsoft/TypeScript/issues/9858

18reactions
blakeembreycommented, Feb 13, 2017

There’s no code in there using ts-node. The error is from tsc. The problem is your dependency - your depending on a TypeScript file outside of src/ and need to fix that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error TS6059: File is not under 'rootDir' .. 'rootDir' is expected ...
One fix is to just remove "rootDir": "src" from compiler options, so it gets set automatically. Caution: rootDir will then consider both ...
Read more >
File is not under 'rootDir' 'packages'. 'rootDir' is expected to ...
File is not under 'rootDir' 'packages'. 'rootDir' is expected to contain all source files in npm preset #10773.
Read more >
File is not under 'rootDir' error in TypeScript | bobbyhadz
The "File is not under 'rootDir'" error occurs when we try to import something from a file that is not located under the...
Read more >
TSConfig Option: rootDir - TypeScript
rootDir. Default: The longest common path of all non-declaration input files. ... the default is instead the directory containing the tsconfig.json file.
Read more >
Diagnostics option | ts-jest - GitHub Pages
6059 : 'rootDir' is expected to contain all source files. 18002 : The 'files' list in config file is empty. (it is strongly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found