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,

12 comments
Comment actions Permalink

proibably because you didn't pass --module <format> to TypeScript compiler? :)

0
Comment actions Permalink

I did but it didn't help

--experimentalDecorators -m commonjs -t es5 --emitDecoratorMetadata

0
Comment actions Permalink

please attach screenshots of your settings anderror message

0
Comment actions Permalink

Screen Shot 2015-12-10 at 10.11.45 AM.png

/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'.

0
Comment actions Permalink

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

0
Comment actions Permalink

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'.


0
Comment actions Permalink

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

0
Comment actions Permalink

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

0
Comment actions Permalink

Can't access it ('you don't have access to this repository')


0
Comment actions Permalink

Please try again.

0
Comment actions Permalink

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:

    "compilerOptions": {
        "module": "commonjs",
        "removeComments": true,
        "preserveConstEnums": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "sourceMap": true,
        "target": "ES5"
    
},
    "exclude": [
            "node_modules",
            "public"
        
]
}


- set up the compiler to use tasconfig for compilation:

compiler.png

0
Comment actions Permalink

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.
Capture d’écran 2016-01-07 à 17.58.29.jpg

Capture d’écran 2016-01-07 à 17.58.45.jpg
Capture d’écran 2016-01-07 à 18.07.05.jpg
I tried to put a custom version of my typescript install 1.7.5, doesn't work too.

See my tsconfig :
Capture d’écran 2016-01-07 à 18.08.29.jpg

Thanks in advance,

0

Please sign in to leave a comment.