TypeScript:如何让WebStorm使用CommonJS而不是AMD(TypeScript: how to tell WebStorm to use CommonJS rather than AMD)

我正在使用WebStorm在TypeScript中构建Node.js应用程序。 当我编写“require”语句时,TypeScript编译器使用AMD。 我通过使用异步模式的js输出来了解它。

我如何告诉WebStorm使用CommonJS?

I'm using WebStorm to build a Node.js app in TypeScript. When I write a "require" statement, the TypeScript compiler uses AMD. I know it by the js output with the asynchronous pattern.

How can I tell WebStorm to use CommonJS instead?

最满意答案

你必须说,编译,例如在npm

选项:

-m, --module Specify module code generation: 'commonjs' or 'amd'

例:

tsc.compile(['test/cases/ship.ts', 'test/cases/fleet.ts'], '-m commonjs -t ES5 --out test/tmp/navy.js');

更多的参考: TypeScript编译器

也可以看看这段视频: TypeScript Modules Demystified:Internal,AMD与RequireJS,CommonJS与NodeJS

You have to say that to compiler, for example in npm

Option:

-m, --module Specify module code generation: 'commonjs' or 'amd'

Example:

tsc.compile(['test/cases/ship.ts', 'test/cases/fleet.ts'], '-m commonjs -t ES5 --out test/tmp/navy.js');

for more refer to: TypeScript compiler

also have a look at this video: TypeScript Modules Demystified : Internal, AMD with RequireJS, CommonJS with NodeJS

TypeScript:如何让WebStorm使用CommonJS而不是AMD(TypeScript: how to tell WebStorm to use CommonJS rather than AMD)

我正在使用WebStorm在TypeScript中构建Node.js应用程序。 当我编写“require”语句时,TypeScript编译器使用AMD。 我通过使用异步模式的js输出来了解它。

我如何告诉WebStorm使用CommonJS?

I'm using WebStorm to build a Node.js app in TypeScript. When I write a "require" statement, the TypeScript compiler uses AMD. I know it by the js output with the asynchronous pattern.

How can I tell WebStorm to use CommonJS instead?

最满意答案

你必须说,编译,例如在npm

选项:

-m, --module Specify module code generation: 'commonjs' or 'amd'

例:

tsc.compile(['test/cases/ship.ts', 'test/cases/fleet.ts'], '-m commonjs -t ES5 --out test/tmp/navy.js');

更多的参考: TypeScript编译器

也可以看看这段视频: TypeScript Modules Demystified:Internal,AMD与RequireJS,CommonJS与NodeJS

You have to say that to compiler, for example in npm

Option:

-m, --module Specify module code generation: 'commonjs' or 'amd'

Example:

tsc.compile(['test/cases/ship.ts', 'test/cases/fleet.ts'], '-m commonjs -t ES5 --out test/tmp/navy.js');

for more refer to: TypeScript compiler

also have a look at this video: TypeScript Modules Demystified : Internal, AMD with RequireJS, CommonJS with NodeJS