最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

构建angular2库时出错

IT培训 admin 2浏览 0评论

构建angular2库时出错

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

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

Thanks

回答如下:

把你的tsconfig.json换成

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

构建angular2库时出错

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

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

Thanks

回答如下:

把你的tsconfig.json换成

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

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论