TypeScript compilation error TS5037: Cannot compile external modules unless the '--module' flag is provided

Also just to add.

I am using Visual Studio 2013 I got this same error running build to fix it. I went to the properties of my project and then to the "TypeScript Build" section in there was the option to pick a module system I selected AMD it was at none.


As mentioned compile with the module flag, e.g. if your file is called myfile.ts :

tsc myfile.ts --module "commonjs" 

The reason is that starting from TSC 0.9.1 the default module option is amd (e.g. requirejs) which is the most common module pattern for client side javascript code. So, you need to specify the module option to get commonjs code which is the most common module pattern for server side javascript code (e.g. nodejs) which is why the compiler is prompting you to be explicit about your target :) This prompt occurs when you do an import on an external module.