parsify-dev / cashify

💸 Lightweight currency conversion library, successor of money.js
MIT License
402 stars 19 forks source link

Unable to import module in Typescript #22

Open krishnaTORQUE opened 2 years ago

krishnaTORQUE commented 2 years ago

Error Error [ERR_REQUIRE_ESM]: require() of ES Module

Code import {convert} from 'cashify';

const { convert }: any = await import('cashify');

const convert: any = (await import('cashify')).convert;

None of those examples above working.

Is there anyone facing this issue ?

xxczaki commented 2 years ago

Please see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

krishnaTORQUE commented 2 years ago

Please see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

Hi Thank you but this doc tells to convert into ESM which I dont want at this moment. I am just dynamically importing the cashify module but it does not work. is there any other way ?

d2xdt2 commented 2 years ago

@krishnaTORQUE I am maintaining an ES2017 fork of this package at https://www.npmjs.com/package/cashify-es2017 , which means it can be used as any other package.