TSError: ⨯ Unable to compile TypeScript?
See original GitHub issueI get this weird error by trying to run a simple script:
class Greeter {
constructor(public greeting: string) { }
greet() {
return "<h1>" + this.greeting + "</h1>";
}
};
var greeter = new Greeter("Hello, world!");
console.log(greeter.greet());
I did:
$ npm install ts-node -g
$ npm install typescript -g
$ ts-node test.ts
And I get the following error:
TSError: ⨯ Unable to compile TypeScript
examples/echo.ts (2,7): Duplicate identifier 'Greeter'. (2300)
at getOutput (/home/arkotek/.nvm/versions/node/v6.3.1/lib/node_modules/ts-node/src/index.ts:258:17)
at /home/arkotek/.nvm/versions/node/v6.3.1/lib/node_modules/ts-node/src/index.ts:267:16
at Object.compile (/home/arkotek/.nvm/versions/node/v6.3.1/lib/node_modules/ts-node/src/index.ts:403:17)
at loader (/home/arkotek/.nvm/versions/node/v6.3.1/lib/node_modules/ts-node/src/index.ts:289:33)
at Object.require.extensions.(anonymous function) [as .ts] (/home/arkotek/.nvm/versions/node/v6.3.1/lib/node_modules/ts-node/src/index.ts:306:14)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at Object.<anonymous> (/home/arkotek/.nvm/versions/node/v6.3.1/lib/node_modules/ts-node/src/_bin.ts:179:12)
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Error: TSError: ⨯ Unable to compile TypeScript - Stack Overflow
I had met same issue. First I remove ts-node and typescript from package.json . then, npm install ts-node --save-dev npm install typescript ......
Read more >TSError: ⨯ Unable to compile TypeScript after version `10.1.0 ...
After upgrading from version 10.0.3 to 10.1.0 cypress shows this error. The typescript file seems to be ignored, the project works fine with...
Read more >I got Unable to compile TypeScript error - CircleCI Discuss
One thing you can do to ensure this is to make sure your executor has Java runtime set up. Based on your config,...
Read more >Troubleshooting | ts-node - TypeStrong · GitHub
Any error that is not a TSError is from node.js (e.g. SyntaxError ), and cannot be fixed by TypeScript or ts-node. These are...
Read more >Compiling TypeScript into JavaScript | IntelliJ IDEA ... - JetBrains
IntelliJ IDEA comes with a built-in TypeScript compiler. By default, it outputs generated JavaScript files and sourcemaps next to the TypeScript ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am also facing this issue while running the test cases for my Aurelia ( + Webpack + TypeScript) app. I have already asked about this in stack overflow: http://stackoverflow.com/questions/41137573/karma-error-config-invalid-config-file. As the TypeScript compilation fails from ts-node, the testing can’t proceed further.
I also tried to do a simple
ts-node test/unit/setup.ts, and I faced the similar issue with that as well:Any suggestion on what I should look for?
Oh, actually, it is your issue. You need to be in the directory to use the correct
tsconfig.jsonfile. This works the same as TypeScript. You’re currently using a differenttsconfig.jsonfile which is for ES5 and not ES6 - when you run it in the correct directory it uses thetsconfig.jsonfile from there instead.