Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot compile external modules unless the '--module' flag is provided

Problem while using visual studio code with angularjs2 and Typescript 1.5beta.

Error:(3, 1) TS1148: Cannot compile external modules unless the '--module' flag is provided.
Error:(6, 1) TS1205: Decorators are only available when targeting ECMAScript 5 and higher.

I can run the same code using the commandline compiler using tsc -t es5 -m commonjs app.ts.The same problem occours with webstorm 10.0.2 as well.

like image 589
Prasanjit Dey Avatar asked May 20 '15 08:05

Prasanjit Dey


2 Answers

This is how I solved it in Webstorm/IntelliJ

File>Settings>Languages & Frameworks > TypeScript

Command Line options:

-m amd -t ES5

like image 182
wizkidblake Avatar answered Oct 02 '22 16:10

wizkidblake


solved it myself on visual studio code. steps:

1)tsd init

2)tsd query angular --action install --save

3)create tsconfig.json .The configuration file looks something like this

{ "compilerOptions": { "target": "ES5", "module": "commonjs", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false } }

but still dont know how to make it work on webstorm

like image 34
Prasanjit Dey Avatar answered Oct 02 '22 15:10

Prasanjit Dey