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

Get error on running ts-node on TypeScript files #353

Open
nikitavoloboev opened this issue Aug 30, 2018 · 4 comments
Open

Get error on running ts-node on TypeScript files #353

nikitavoloboev opened this issue Aug 30, 2018 · 4 comments

Comments

@nikitavoloboev
Copy link

Below is the error:

[Running] ts-node "/Users/nikivi/src/test/ts-test/test.ts"

/Users/nikivi/.npm-global/lib/node_modules/ts-node/src/index.ts:261
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
error TS5023: Unknown compiler option 'exclude'.

    at createTSError (/Users/nikivi/.npm-global/lib/node_modules/ts-node/src/index.ts:261:12)
    at Object.register (/Users/nikivi/.npm-global/lib/node_modules/ts-node/src/index.ts:265:42)
    at Object.<anonymous> (/Users/nikivi/.npm-global/lib/node_modules/ts-node/src/bin.ts:113:17)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)

[Done] exited with code=1 in 0.332 seconds

I have both ts-node and typescript installed globally with npm i -g.

I can run the above file in my shell but not with Code Runner:

❯  ts-node "/Users/nikivi/src/test/ts-test/test.ts"
test
@formulahendry
Copy link
Owner

Did you try closing all VS Code, and start VS Code and then try again?

@nikitavoloboev
Copy link
Author

Did you try closing all VS Code, and start VS Code and then try again?

Tried that. Same error:

[Running] ts-node "/Users/nikivi/src/test/ts-test/test.ts"

/Users/nikivi/.npm-global/lib/node_modules/ts-node/src/index.ts:261
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
error TS5023: Unknown compiler option 'exclude'.

    at createTSError (/Users/nikivi/.npm-global/lib/node_modules/ts-node/src/index.ts:261:12)
    at Object.register (/Users/nikivi/.npm-global/lib/node_modules/ts-node/src/index.ts:265:42)
    at Object.<anonymous> (/Users/nikivi/.npm-global/lib/node_modules/ts-node/src/bin.ts:113:17)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)

[Done] exited with code=1 in 0.381 seconds

@formulahendry
Copy link
Owner

Please use below setting (File->Preference->Settings) to run code in Integrated Terminal:

{
    "code-runner.runInTerminal": true
}

@ak99372
Copy link

ak99372 commented Jan 2, 2020

I think the issue is that the code runner executes command in root folder! If your package/project (including tsconfig) is a sub folder you will run into this issue.
The solution is then to make sure the project's folder is in workspace on its own (you can just re-add the folder into workspace again but make sure to run the code from there).

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

3 participants