Ignoring "exclude" from tsconfig.json

See original GitHub issue

I’m pretty sure ts-node is ignoring the exclude option in tsconfig.json. I get no errors when using tsc directly.

tsconfig.json

{
    "compileOnSave": false,
    "compilerOptions": {
        "target": "es5",
        "allowJs": true,
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false,
        "types": [
            "node"
        ]
    },
    "exclude": [
        "node_modules",
    ]
}

ts-node main.ts


~/.nvm/versions/node/v6.7.0/lib/node_modules/ts-node/src/index.ts:308
          throw new TSError(diagnosticList)
                ^
TSError: ⨯ Unable to compile TypeScript
node_modules/json-schema/lib/validate.js (43,10): Duplicate identifier 'validate'. (2300)
node_modules/json-schema/lib/validate.js (68,5): Duplicate identifier 'validate'. (2300)
    at getOutput (~/.nvm/versions/node/v6.7.0/lib/node_modules/ts-node/src/index.ts:308:17)
    at ~/.nvm/versions/node/v6.7.0/lib/node_modules/ts-node/src/index.ts:334:18
    at Object.compile (~/.nvm/versions/node/v6.7.0/lib/node_modules/ts-node/src/index.ts:488:17)
    at Module.m._compile (~/.nvm/versions/node/v6.7.0/lib/node_modules/ts-node/src/index.ts:392:44)
    at Module._extensions..js (module.js:565:10)
    at Object.require.extensions.(anonymous function) [as .js] (~/.nvm/versions/node/v6.7.0/lib/node_modules/ts-node/src/index.ts:395:12)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)

Also I know there is a duplicate identifier error in json-schema but using tsc main.ts and then node main.js works correctly with no changes.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
ravi005ecommented, Dec 27, 2019

Ok, I found the issue. Since 1.4.0, the added --ignore option (which could override the default node_modules ignore) was faulty - which resulted in it ignoring nothing and compiling node_modules files (a behaviour previously avoided on purpose). I’ve fixed the flag with 1.6.0. Let me know if that works for you 😄

How did you added it, It doesn’t work for me. can you provide an example? thanks

1reaction
jperlcommented, Oct 16, 2016

That fixed it. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

"exclude" property of tsconfig.json is not being respected
As for include/exclude not working, I believe it is because of "dependencies." Even if you exclude a folder, if an imported file (like...
Read more >
Exclude a Folder from compilation with tsconfig.json in TS
Use the exclude option in your tsconfig.json file to exclude a folder from compilation in TypeScript. The exclude option changes what the include...
Read more >
tsconfig exclude field not working · Issue #38475 - GitHub
Using TSC 3.8.3, run tsc --init . In the tsconfig.json file, add the line: exclude: ["**/node_modules/*"]. Add a package.json dependency ...
Read more >
Typescript Compiler not ignoring excluded paths - YouTrack
1. Add a directory (root -> directory) with typescript files in it. · 2. Add this directory to the "exclude" option in the...
Read more >
exclude - TSConfig Option - TypeScript
How this setting affects your build.
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