构建angular2库时出错

时间:2017-12-24 08:27:09

标签: node.js angular build

这是我用于构建

的tsconfig-build.json

{ "compilerOptions": { "target": "es5", "module": "es2015", "sourceMap": true, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "declaration": true, "outDir": "../dist" }, "files": ["./index.ts"], "angularCompilerOptions": { "genDir": "compiled", "strictMetadataEmit": true, "skipTemplateCodegen": true }, "exclude": [ "node_modules", "dist", "gh-pages", "**/*.ngfactory.ts", "**/*.shim.ts", "**/*.spec.ts" ] }

这是我的package.json文件中的脚本

"scripts": { "prebuild": "rimraf ./dist ./compiled", "build": "ngc -p ./src/tsconfig-build.json" },

在运行脚本npm run build时,我错过了下面列出的错误。

../node_modules/@angular/core/src/di/reflective_provider.d.ts(87,123): error TS2304: Cannot find name 'Map'. ../node_modules/@angular/core/src/di/reflective_provider.d.ts(87,165): error TS2304: Cannot find name 'Map'. ../node_modules/rxjs/Observable.d.ts(58,60): error TS2693: 'Promise' only refers to a type, but is being used as a value here. ../node_modules/rxjs/Observable.d.ts(73,59): error TS2693: 'Promise' only refers to a type, but is being used as a value here. ../node_modules/@angular/core/src/change_detection/differs/iterable_differs.d.ts(14,48): error TS2304: Cannot find name 'Iterable'. ../node_modules/@angular/core/src/change_detection/differs/keyvalue_differs.d.ts(22,18): error TS2304: Cannot find name 'Map'. ../node_modules/@angular/core/src/change_detection/differs/default_iterable_differ.d.ts(12,32): error TS2304: Cannot find name 'Iterable'.../node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,16): error TS2304: Cannot find name 'Map'. ../node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(32,16): error TS2304: Cannot find name 'Map'. ../node_modules/@angular/common/src/directives/ng_class.d.ts(48,34): error TS2304: Cannot find name 'Set'. ../node_modules/ionic-angular/util/module-loader.d.ts(13,14): error TS2304: Cannot find name 'Map'. ../node_modules/ionic-angular/util/module-loader.d.ts(14,18): error TS2304: Cannot find name 'Map'. ../node_modules/ionic-angular/util/base-input.d.ts(2,38): error TS2307: Cannot find module '@angular/forms'. ../node_modules/ionic-angular/util/base-input.d.ts(3,27): error TS2307: Cannot find module '@angular/forms'. ../node_modules/ionic-angular/components/datetime/datetime.d.ts(2,38): error TS2307: Cannot find module '@angular/forms'. ../node_modules/ionic-angular/components/input/input.d.ts(2,27): error TS2307: Cannot find module '@angular/forms'. ../node_modules/ionic-angular/components/range/range.d.ts(2,38): error TS2307: Cannot find module '@angular/forms'. ../node_modules/ionic-angular/components/searchbar/searchbar.d.ts(2,27): error TS2307: Cannot find module '@angular/forms'. ../node_modules/ionic-angular/components/segment/segment.d.ts(2,27): error TS2307: Cannot find module '@angular/forms'. ../node_modules/ionic-angular/gestures/gesture-config.d.ts(1,37): error TS2307: Cannot find module '@angular/platform-browser'.

  

它是离子应用程序的简单角度指令,可能是什么原因   以上缺少的陈述?

感谢

1 个答案:

答案 0 :(得分:1)

tsconfig.json 更改为

 "compilerOptions": {
    "target": "es5",
    "lib": ["es5", "es6", "dom"],  <--- this
    ...
  }