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
+-- [email protected]
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)
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.
Closing with an update to docs: https://github.com/TypeStrong/ts-node/commit/e7591c7e70c95152d8fd1380571ff870192c475e.
@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?
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.
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.
Aren't environment variables also limited to strings? Seems like that would cause the same issue...
The string is parsed as a boolean, so no.
But not that one I guess, so yes. Open to PRs.
This should add SKIP_xxx and --skip-xxx to config flags.
--no-project useless, sad. Still can not ignore tsconfig.json
@blakeembrey I authored a PR to fix this.
Should be possible again now with https://github.com/TypeStrong/ts-node/pull/536. Thanks for your patience.
Solution:
ts-node --skip-project MyScript.ts
Most helpful comment
Solution:
ts-node --skip-project MyScript.ts