使用 angular cli 构建 angular2 项目时 angular2-clipboard 出错

Error in angular2-clipboard while building angular2 project with angular cli

使用 ng build 构建我的 angular2 项目时出现以下错误

Error in bail mode: [default] /Users/erikwitt/Documents/git/workflow-lights/node_modules/angular2-clipboard/src/clipboard.directive.ts:2:0 
Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.

不确定 angular2-clipboard 为什么会出现此 TypeScript 错误。 Every thinks 在 ng server.

的开发中工作得很好

我的tsconfig.json如下:

{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
  "es6",
  "dom",
  "es2015.collection"
],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
  "../node_modules/@types"
]
}
}

看起来 angular2-clipboard 不适用于 es6 模块配置。尝试将其更改为 commonjs:

{
   "compilerOptions": {
     "declaration": false,
     "emitDecoratorMetadata": true,
     "experimentalDecorators": true,
     "lib": [
       "es6",
       "dom",
       "es2015.collection"
     ],
     "mapRoot": "./",
     "module": "commonjs",
     "moduleResolution": "node",
     "outDir": "../dist/out-tsc",
     "sourceMap": true,
     "target": "es5",
     "typeRoots": [
       "../node_modules/@types"
     ]
   }
}