【问题标题】:Error building angular2 library构建 angular2 库时出错
【发布时间】:2018-06-06 03:35:54
【问题描述】:

这是我用来构建的 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'.

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

谢谢

【问题讨论】:

    标签: node.js angular build


    【解决方案1】:

    将您的 tsconfig.json 更改为

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-25
      • 1970-01-01
      • 2017-11-22
      • 1970-01-01
      • 2016-01-10
      • 2016-03-22
      • 1970-01-01
      相关资源
      最近更新 更多