LoginSignup
0
0

More than 5 years have passed since last update.

Typescriptで外部moduleコンパイル時にTS1148のエラーが発生する場合

Last updated at Posted at 2015-10-06

例えば、下記のような外部moudleをtscコマンドでコンパイルします。

ts
export function externalFunc(){
  alert('externalFunc')
}
tscコマンド
tsc -w hoge.ts

結果下記のようなエラーが発生しました。

error TS1148: Cannot compile modules unless the '--module' flag is provided.

コンパイル時に'--module'をオプションとして設定する必要があるようです。

tscコマンド
tsc --module amd -w hoge.ts

//もしくは下記とか
//tsc --module commonjs -w hoge.ts

上記でエラーが発生せずにコンパイルすることができました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0