Skip to content

Not possible to ignore tsconfig.json #456

Closed

Description

@NaridaL

I'm trying to get ts-node to behave as if there was no tsconfig in the current directory. Unless I'm misunderstanding the readme (https://github.com/TypeStrong/ts-node#loading-tsconfigjson), this should be possible...

in an empty directory:

PS C:\Users\aval\tsdev\nla\tsnodetest> echo "ERROR" > tsconfig.json
PS C:\Users\aval\tsdev\nla\tsnodetest> echo "console.log('foobar')" > index.ts
PS C:\Users\aval\tsdev\nla\tsnodetest> node -v
v8.7.0
PS C:\Users\aval\tsdev\nla\tsnodetest> npm -v
5.5.1
PS C:\Users\aval\tsdev\nla\tsnodetest> npm list ts-node -g
C:\npm
+-- ts-node@3.3.0
PS C:\Users\aval\tsdev\nla\tsnodetest> ts-node -P false .\index.ts
TypeError: The specified path does not exist: false
    at resolveSync (C:\npm\node_modules\ts-node\node_modules\tsconfig\src\tsconfig.ts:72:9)
    at Object.loadSync (C:\npm\node_modules\ts-node\node_modules\tsconfig\src\tsconfig.ts:140:16)
    at readConfig (C:\npm\node_modules\ts-node\src\index.ts:425:18)
    at Object.register (C:\npm\node_modules\ts-node\src\index.ts:189:18)
    at Object.<anonymous> (C:\npm\node_modules\ts-node\src\_bin.ts:140:17)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
PS C:\Users\aval\tsdev\nla\tsnodetest> ts-node -n .\index.ts
SyntaxError: Unexpected token � in JSON at position 0
    at JSON.parse (<anonymous>)
    at parse (C:\npm\node_modules\ts-node\node_modules\tsconfig\src\tsconfig.ts:195:15)
    at readFileSync (C:\npm\node_modules\ts-node\node_modules\tsconfig\src\tsconfig.ts:181:10)
    at Object.loadSync (C:\npm\node_modules\ts-node\node_modules\tsconfig\src\tsconfig.ts:151:18)
    at readConfig (C:\npm\node_modules\ts-node\src\index.ts:425:18)
    at Object.register (C:\npm\node_modules\ts-node\src\index.ts:189:18)
    at Object.<anonymous> (C:\npm\node_modules\ts-node\src\_bin.ts:140:17)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)

Activity

  1. blakeembrey commented on Nov 16, 2017

    @blakeembrey
    Member

    Can you try with --no-project? It looks like the README is incorrect, since it relies on an underlying library to correctly parse the CLI arguments and --project false would just be interpreted as a string.

  2. blakeembrey commented on Nov 16, 2017

    @blakeembrey
    Member

    Closing with an update to docs: e7591c7.

  3. NaridaL commented on Nov 16, 2017

    @NaridaL
    ContributorAuthor

    @blakeembrey
    What about

    Typescript Node uses tsconfig.json automatically, use -n to skip loading tsconfig.json.

    https://github.com/TypeStrong/ts-node#loading-tsconfigjson

    Also, what is the correct setting when using environment variables?

  4. blakeembrey commented on Nov 16, 2017

    @blakeembrey
    Member

    If you want to submit a PR, go for it. But -n isn’t anything, and the no prefix is for multiple parts. It’s false for the environment variable.

  5. blakeembrey commented on Nov 16, 2017

    @blakeembrey
    Member

    Oh, I see now, I have another place to update. Feel free to still submit a PR, otherwise I’ll get to it as I can.

  6. NaridaL commented on Nov 30, 2017

    @NaridaL
    ContributorAuthor

    Aren't environment variables also limited to strings? Seems like that would cause the same issue...

  7. blakeembrey commented on Dec 1, 2017

    @blakeembrey
    Member

    The string is parsed as a boolean, so no.

  8. blakeembrey commented on Dec 1, 2017

    @blakeembrey
    Member

    But not that one I guess, so yes. Open to PRs.

  9. blakeembrey commented on Dec 7, 2017

    @blakeembrey
    Member

    This should add SKIP_xxx and --skip-xxx to config flags.

  10. xiaoqf10 commented on Dec 15, 2017

    @xiaoqf10

    --no-project useless, sad. Still can not ignore tsconfig.json

  11. added 2 commits that reference this issue on Jan 22, 2018
    c9d510e
    229d37a
  12. NaridaL commented on Jan 22, 2018

    @NaridaL
    ContributorAuthor

    @blakeembrey I authored a PR to fix this.

  13. blakeembrey commented on Feb 19, 2018

    @blakeembrey
    Member

    Should be possible again now with #536. Thanks for your patience.

  14. NikoAri commented on Mar 11, 2020

    @NikoAri

    Solution:
    ts-node --skip-project MyScript.ts

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions