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

Not possible to ignore tsconfig.json #456

Closed
NaridaL opened this issue Nov 4, 2017 · 13 comments
Closed

Not possible to ignore tsconfig.json #456

NaridaL opened this issue Nov 4, 2017 · 13 comments

Comments

@NaridaL
Copy link
Contributor

NaridaL commented Nov 4, 2017

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)
@blakeembrey
Copy link
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.

@blakeembrey
Copy link
Member

Closing with an update to docs: e7591c7.

@NaridaL
Copy link
Contributor Author

NaridaL commented Nov 16, 2017

@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?

@blakeembrey
Copy link
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.

@blakeembrey
Copy link
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.

@NaridaL
Copy link
Contributor Author

NaridaL commented Nov 30, 2017

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

@blakeembrey
Copy link
Member

The string is parsed as a boolean, so no.

@blakeembrey
Copy link
Member

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

@blakeembrey blakeembrey reopened this Dec 7, 2017
@blakeembrey
Copy link
Member

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

@xiaoqf10
Copy link

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

NaridaL added a commit to NaridaL/ts-node that referenced this issue Jan 22, 2018
Fixes TypeStrong#456
process env variables are always strings, see https://nodejs.org/api/process.html#process_process_env,
so I added TS_NODE_NO_PROJECT to set project === false
NaridaL added a commit to NaridaL/ts-node that referenced this issue Jan 22, 2018
Fixes TypeStrong#456
process env variables are always strings, see https://nodejs.org/api/process.html#process_process_env,
so I added TS_NODE_NO_PROJECT to set project === false
@NaridaL
Copy link
Contributor Author

NaridaL commented Jan 22, 2018

@blakeembrey I authored a PR to fix this.

@blakeembrey
Copy link
Member

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

@NikoAri
Copy link

NikoAri commented Mar 11, 2020

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants