Prasanjit Dey
Prasanjit Dey

Reputation: 6014

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.

Upvotes: 9

Views: 7364

Answers (3)

shotleybuilder
shotleybuilder

Reputation: 123

I was getting the same error using Visual Studio Code and ng2-meteor.

Not sure if the angular.d.ts created with the 2nd tsd command is needed, but this tsconfig.json seemed to sort things:

{
  "compilerOptions": {
    "module": "system",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  }
}

Upvotes: 0

Prasanjit Dey
Prasanjit Dey

Reputation: 6014

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

Upvotes: 6

wizkidblake
wizkidblake

Reputation: 111

This is how I solved it in Webstorm/IntelliJ

File>Settings>Languages & Frameworks > TypeScript

Command Line options:

-m amd -t ES5

Upvotes: 11

Related Questions