Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
0 answers
15 views

Commonjs and ES6. Import doesn't work on module

I'm on react, I have a file I need to run on a command like this "runFunction": "npx ts-node ./src/seedParkStreetSalesData.js" And this is the file /* import { Op } from '...
alexgarciaalcuadrado's user avatar
0 votes
2 answers
787 views

Dynamically load ESM module in CJS package in TypeScript

I am trying to load a single ESM module in my TypeScript CJS project. All examples I find are for JavaScript. // example.ts export const example = async () => { const module = await import("...
myol's user avatar
  • 9,780
2 votes
2 answers
970 views

Trying to import KcAdminClient

I’m trying to use the Keycloak Admin Client library in my Nodejs (Typescript) application, but there's a problem about ES6/CommonJs stuff, which I never really understood (import vs require and mixing ...
Lucio Crusca's user avatar
  • 1,507
0 votes
1 answer
442 views

async import() function from CommonJS to load ESM asynchronously:

I am trying to use one npm package which is ESM https://www.npmjs.com/package/key-did-resolver I can not require the 'key-did-resolver' package after installation as it's ESM , So I am trying to load ...
Mostafa0707's user avatar
1 vote
0 answers
708 views

How to set-up a .mjs file when importing from cjs?

I'm using a third party library that provides an index.js and index.mjs file. The package.json has this: "exports": { "import": "./index.mjs", "require": &...
user1087973's user avatar
  • 1,108
0 votes
1 answer
813 views

Include a few ES style npm modules into a project with mostly commonJS modules

I have browsed a lot of questions in this space, but I haven't found a clear answer. I recently updated many of my project's npm dependencies to their latest. The project is entirely built around ...
farhadf's user avatar
  • 1,968
0 votes
1 answer
130 views

Rollupjs Leave imports unchanged

My input file looks like this: import * as chalk from 'chalk' const chalkInstance = new chalk.Instance({ level: 1 }) My output file looks like this: import { Instance } from 'chalk'; const ...
LionKing's user avatar
  • 141
0 votes
2 answers
496 views

Is it possible to use ES6 import without creating a variable and execute in a single line, similar to CommonJS?

Just wondering, am I able to import ES6 modules without creating a "placeholder" variable and run it immediately? for instance, instead of ES6's import that creates an unused express variable: ...
Jamie Phan's user avatar