Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 views
in Technique[技术] by (71.8m points)

angular - Import assignment cannot be used when targeting ECMAScript 2015 modules

I'm trying to use the follwing line:

import Clipboard = require('clipboard');

and I get the following error:

   [default] c:xampphtdocsisitperfect
ode_modulesangular2-clipboardsrcclipboard.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.

The error is in this line:

import Clipboard = require('clipboard');

I tried:

import * as Clipboard from 'clipboard';

and some other variations but couldn't figure out how to fix it.

I'm using typescript 2.0.0

Any ideas?

question from:https://stackoverflow.com/questions/39664068/import-assignment-cannot-be-used-when-targeting-ecmascript-2015-modules

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I was facing the same issue as you.

In the tsconfig.json file I replaced:

"module": "es6"

with

"module": "commonjs"

and restarted the terminal. It worked.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...