2015-05-20 49 views
9

使用帶有angularjs2和Typescript 1.5beta的visual studio代碼時出現問題。無法編譯外部模塊,除非提供'--module'標誌

Error:(3, 1) TS1148: Cannot compile external modules unless the '--module' flag is provided.
Error:(6, 1) TS1205: Decorators are only available when targeting ECMAScript 5 and higher.

我可以用用 TSC -t ES5 -m CommonJS的app.ts.The同樣的問題,在命令行編譯器運行相同的代碼webstorm 10.0.2 occours爲好。

回答

6

自己用visual studio代碼解決了它。 步驟:

1)TSD INIT

2)TSD查詢角--action安裝--save

3)創建tsconfig.json .The配置文件看起來是這樣的

{ "compilerOptions": { "target": "ES5", "module": "commonjs", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false } }

,但仍然不知道如何使它在webstorm工作

+2

有關'tsconfig.json'看到HTTPS的詳細信息: //github.com/Microsoft/TypeScript/wiki/tsconfig.json – jbandi

+1

在webstorm中,您可以在首選項 - >語言和框架 - > TypeScript – jbandi

+0

上添加命令行選項'--module commonjs',然後添加命令行選項,如「--module commonjs「它顯示錯誤無法啓動編譯器程序 –

11

這是我如何解決它Webstorm /的IntelliJ

文件>設置>語言&框架>打字稿

命令行選項:

-m AMD -t ES5

+0

對Ecmascript 6使用'-m amd -t ES6' – HasanAboShally

0

我正在使用Visual Studio代碼相同的錯誤和ng2-meteor。

不知道是否與第二TSD命令創建的angular.d.ts是必要的,但是這似乎tsconfig.json的事情進行排序:

{ 
    "compilerOptions": { 
    "module": "system", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": false 
    } 
} 
相關問題