I\'m trying to use the follwing line:
import Clipboard = require(\'clipboard\');
and I get the following error:
[default] c:
Try to set module as commonjs in tsconfig
You can try this example using webpack here
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
.
I used default
member of imported function.
import {default as Clipboard} from 'clipboard';
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.
I had the same problem after updating my vsCode.
just replace with "module": "es5"
to "module": "commonjs"
in tsconfig.app.json
Similar to KristianC, I got this warning for lodash on upgrade to Angular 11
const cloneDeep = require('lodash-es/cloneDeep');
"Import assignment cannot be used when targeting ECMAScript modules."
Warning resolved on updating "require" to "import"
import { cloneDeep } from 'lodash-es';