Typescript transpile error TS1148
I figure out why I'm getting this error:
error TS1148: Cannot compile modules unless the '--module' flag is provided.
/workspace/my-app/app.ts(1,45): error TS2307: Cannot find module 'angular2/angular2'.
I'm running PhpStorm 9, node 5.0.0, tsc v1.6.2
Thanks,
Please sign in to leave a comment.
proibably because you didn't pass --module <format> to TypeScript compiler? :)
I did but it didn't help
--experimentalDecorators -m commonjs -t es5 --emitDecoratorMetadata
please attach screenshots of your settings anderror message
/usr/local/bin/tsc --sourcemap /Users/my-app/app.ts
/Users/my-app/app.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided.
/Users/my-app/app.ts(1,45): error TS2307: Cannot find module 'angular2/angular2'.
/Users/my-app/app.ts(2,36): error TS2307: Cannot find module 'angular2/http'.
/Users/my-app/app.ts(4,30): error TS2307: Cannot find module './serviceManager.js'.
/Users/my-app/app.ts(5,25): error TS2307: Cannot find module './orderList.js'.
/Users/my-app/app.ts(6,28): error TS2307: Cannot find module './orderDetails.js'.
/Users/my-app/app.ts(7,27): error TS2307: Cannot find module './itemDetails.js'.
/Users/my-app/app.ts(8,24): error TS2307: Cannot find module './starship.js'.
/Users/my-app/app.ts(11,1): error TS1205: Decorators are only available when targeting ECMAScript 5 and higher.
/Users/my-app/app.ts(17,7): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.
/Users/my-app/app.ts(29,10): error TS2339: Property 'sm' does not exist on type 'AppComponent'.
You have set options for built-in compiler, but definitely the errors come not from it, but from tsc you run in terminal (or, may be, using file watchers)? Please attach a screenshot of typescript command line so that I can see where this output is printed
Thanks for pointing that out I do have a file watcher. I thought the file watcher will trigger the built-in compiler. I just passed in the params in the arguments for tsc but this time is getting
/usr/local/bin/tsc --experimentalDecorators -m commonjs -t es5 --emitDecoratorMetadata --sourcemap /Users/my-app/app.ts
/Users/my-app/app.ts(4,30): error TS2307: Cannot find module './serviceManager.js'.
/Users/my-app/app.ts(5,25): error TS2307: Cannot find module './orderList.js'.
/Users/my-app/app.ts(6,28): error TS2307: Cannot find module './orderDetails.js'.
/Users/my-app/app.ts(7,27): error TS2307: Cannot find module './itemDetails.js'.
/Users/my-app/app.ts(8,24): error TS2307: Cannot find module './starship.js'.
/Users/my-app/app.ts(28,10): error TS2339: Property 'sm' does not exist on type 'AppComponent'.
Seems that modules referenced from your .ts files can't be found. that's all I can tell from the stack trace. If you can provide a project, I'd probably find a reason
I have this test project up on bitbucket https://bitbucket.org/playbox21/wu-ng2
couldn't get it to compile in phpstorm, I switched to use gulp to do the transpiling (however getting run time error TypeError: Cannot read property 'getOptional' of undefined)
Either way, please let me know if you can't get to the repo
Can't access it ('you don't have access to this repository')
Please try again.
I can suggest the following: either use Gulp for compiling, or try the built-in compiler.
If you choose the latter way:
- delete/disable your file watcher
- modify the root tsconfig.json as follows:
- set up the compiler to use tasconfig for compilation:
I'm trying on PHPSTORM 10.




I follow the Angular QuickStart steps. The application is running correctly.
But the compiler displays always the same error of Jeff Lu. I don't understand.
I tried to put a custom version of my typescript install 1.7.5, doesn't work too.
See my tsconfig :
Thanks in advance,