Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'rootDir' is expected to contain all source files #270

Closed
ppparihar opened this issue Feb 13, 2017 · 5 comments
Closed

'rootDir' is expected to contain all source files #270

ppparihar opened this issue Feb 13, 2017 · 5 comments

Comments

@ppparihar
Copy link

ppparihar commented Feb 13, 2017

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"
    ]
}
@blakeembrey
Copy link
Member

Can you share the commands you're running? Since ts-node is really just tsc in-memory, it seems there must be some other difference here. Why and how are you running .ts files from node_modules anyway?

@ppparihar
Copy link
Author

ppparihar commented Feb 13, 2017

Below is the package.json

  "name": "tconsole",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"node server.js\" ",
    "e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
    "lint": "tslint ./app/**/*.ts -t verbose",
    "lite": "lite-server",
    "pree2e": "webdriver-manager update",
    "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
    "test-once": "tsc && karma start karma.conf.js --single-run",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "build": "tsc",
    "node-start": "node server.js"
  },
  "dependencies": {
    "@angular/common": "~2.4.0",
    "@angular/compiler": "~2.4.0",
    "@angular/core": "~2.4.0",
    "@angular/forms": "~2.4.0",
    "@angular/http": "~2.4.0",
    "@angular/material": "^2.0.0-beta.1",
    "@angular/platform-browser": "~2.4.0",
    "@angular/platform-browser-dynamic": "~2.4.0",
    "@angular/router": "~3.4.0",
    "@vaadin/angular2-polymer": "^1.0.0",
    "angular-in-memory-web-api": "~0.2.4",
    "aws-sdk": "^2.12.0",
    "body-parser": "~1.15.1",
    "chalk": "^1.1.3",
    "connect-flash": "^0.1.1",
    "connect-mongo": "^1.3.2",
    "cookie-parser": "~1.4.3",
    "cookie-session": "^2.0.0-alpha.1",
    "core-js": "^2.4.1",
    "csurf": "^1.9.0",
    "debug": "~2.2.0",
    "ejs": "^2.5.2",
    "express": "~4.13.4",
    "express-session": "^1.14.1",
    "formidable": "^1.1.1",
    "gulp-copy": "^1.0.0",
    "kontainer-di": "~0.9.9",
    "mongoose": "^4.6.0",
    "mongoose-user": "0.0.1",
    "ngx-uploader": "^2.1.6",
    "node-uuid": "^1.4.7",
    "passport": "^0.3.2",
    "passport-local": "^1.0.0",
    "rxjs": "5.0.1",
    "serve-favicon": "~2.3.0",
    "systemjs": "0.19.40",
    "winston": "^2.2.0",
    "zone.js": "^0.7.4"
  },
  "devDependencies": {
    "@types/jasmine": "^2.5.36",
    "@types/node": "^6.0.46",
    "browser-sync": "^2.18.7",
    "canonical-path": "0.0.2",
    "concurrently": "^3.1.0",
    "gulp": "^3.9.1",
    "gulp-watch": "^4.3.11",
    "http-server": "^0.9.0",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "lite-server": "^2.2.2",
    "lodash": "^4.16.4",
    "morgan": "~1.7.0",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",
    "tslint": "^3.15.1",
    "typescript": "~2.0.10"
  }
}

This .ts file came with ngx-uploader and don't know why it's being compile. tried to exclude it but didn't work.

@blakeembrey
Copy link
Member

blakeembrey commented 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.

@cicibobo
Copy link

How to fix this issue if it is node_modules package ?

@0x-leen
Copy link

0x-leen commented Aug 16, 2018

should exclude all source filesin tsconfig.json,example:

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

here /tests contain ts source files.
see: microsoft/TypeScript#9858

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants