1

I'm having a trouble with compilling my TypeScript file:

app/app.component.ts

import {Component} from 'angular2/core';

@Component({
    selector: 'my-app',
    template: '<h1>Messenger</h1>'
})
export class AppComponent { }

TypeScript Compiller returns

Error:(1, 1) TS1148: Cannot compile modules unless the '--module' flag is provided.
Error:(1, 25) TS2307: Cannot find module 'angular2/core'.
Error:(7, 14) TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.

Providing flags in tsconfig.json does nothing.

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}

My project tree:

.
├── app
├── node_modules
├── typings
├── application.js
├── messages.js
├── package.json
├── tsconfig.json
└── typings.json

I'm using RubyMine 8 as IDE

What am I doing wrong? Is there another way to provide my flags?

2
  • 1
    A few ideas: (1) make sure you have at least typescript 1.5, which is when support for tsconfig.json was added, (2) make sure you are not invoking tsc from a folder that is a parent of your project (tsc will search up but not down for a tsconfig.json file, (3) make sure you are not invoking tsc with input files on the command line (causes tsconfig.json to be ignored). If none of these help, can you provide some details about how you are executing tsc?
    – gxclarke
    Mar 20, 2016 at 1:57
  • Which TypeScript compiler are you using? The one bundled with RubyMine or with the command line?
    – user3348051
    Mar 20, 2016 at 6:34

2 Answers 2

2

If you are using the bundled TypeScript compiler, go to File > Settings > Languages & Frameworks > TypeScript

You can click on the set options manually radio button, and enter the arguments in the Command line options text box. See the list of available arguments

webstorm typescript configuration

This is how you provide command line arguments.

Use tsconfig.json works for me without providing any command line arguments.

0

I might be missing something, but I think there're two errors in your first line of your app.component.ts

import {Component} from 'angular2/core';

should be

import { Component } from '@angular2/core';

The space between the imports and the curly brackets and the '@' symbol before angular2 have caused me lots and lots of pain.

1
  • I asked this question when Angular 2 was an early beta, so syntax might change.
    – Viktor
    Aug 3, 2016 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.