2016-10-20 77 views
0

當構建我angular2項目,ng build我收到以下錯誤錯誤angular2剪貼板,同時建設有角CLI 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得到這個打字稿錯誤。每個人都認爲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" 
] 
} 
} 

回答

0

它看起來像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" 
    ] 
    } 
} 
+0

Jeah!這樣可行。謝謝! – Erik