Cannot compile modules using option 'outFile' unless the '--module' flag is 'amd' or 'system'
I had the same error using gulp to compile typescript to js in Visual Studio 2017.My solution was to not use the outFile option without the module: "system" option (see first option https://github.com/ivogabe/gulp-typescript).
My setup:Visual Studio 2017 15.7.4packages.json > "gulp-typescript": "4.0.2", "typescript": "2.8.4", "@types/jquery": "3.3.4"
typescript compile task in gulpfile.js
gulp.src(source) .pipe(ts({ noImplicitAny: true, //outFile: output, //module: "system" })).pipe(gulp.dest(destination));
When using outFile: output without module: "system" I got the error:Scripts\Test.ts(1,1): error TS6131: Cannot compile modules using option 'outFile' unless the '--module' flag is 'amd' or 'system'.
Just for others searching for an answer if other info above does not help.
You might try
//import a from './a';//import b from './b';namespace myprojectexport class myclass { a, b};}
where 'a' and 'b' are in that namespace , or import them.
I was working on this for several hours - I hope this helps someone!
You should be using a tool like webpack to bundle multiple typescript files into a single javascript file.