Import assignment cannot be used when targeting ECMAScript 2015 modules

大兔子大兔子 提交于 2019-12-03 04:27:18
Shashikant Pandit

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.

KrystianC

I had the same problem and changing to:

import * as myGlobals from "../globals";

fixed the problem. globals.ts file is in the main app folder, and I'm loading it up from subfolder services.

In case you are using Angular CLI: I was able to compile my project after I had set the value of module to es2016 in the file src/tsconfig.app.json.

Try to set module as commonjs in tsconfig

You can try this example using webpack here

Tauseef Ahmed

I had the same problem after updating my vsCode.

just replace with "module": "es5"

to "module": "commonjs" in tsconfig.app.json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!