我想将Angular 2项目编译为commonjs
模块。
我有tsconfig.json
:
{
"compilerOptions": {
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"mapRoot": "./",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../dist/lib",
"sourceMap": true,
"target": "es5",
"removeComments": true
}
}
我使用ntsc
我遇到了这些错误:
node_modules/@angular/common/src/directives/ng_class.d.ts(46,34): error TS2304: Cannot find name 'Set'.
node_modules/@angular/common/src/pipes/async_pipe.d.ts(44,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/aot/compiler.d.ts(32,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/aot/compiler.d.ts(44,32): error TS2304: Cannot find name 'Map'.
我有npm
版本4.0.5
,node
v7.3.0
和ntsc
Version 2.1.0
答案 0 :(得分:1)
您想要target: "es6"
,ECMAScript 5中没有这些缺失的类
答案 1 :(得分:1)
要转换为es5,您必须在主ts文件中添加以下引用:
///<reference path="node_modules/angular2/typings/browser.d.ts"/>