extract-email-address icon indicating copy to clipboard operation
extract-email-address copied to clipboard

`TypeError: extractEmail is not a function`

Open yarekc opened this issue 2 years ago • 1 comments
trafficstars

test.mjs

import extractEmail from 'extract-email-address';
extractEmail('extracts email from anywhere within the input [email protected]');

node test.msj

TypeError: extractEmail is not a function

I also tried with require()

yarekc avatar Aug 18 '23 14:08 yarekc

Any update yet? i face the same issue

hbrks avatar Apr 22 '24 14:04 hbrks

For me, require() did not work as well, but the below resolved the isssue. I'm not totally sure why but jfyi:

  1. create a file foo.d.ts somewhere in your project
declare module 'extract-email-address' {
  function extractEmail(str: string): { email: string }[];
  export = extractEmail;
}
  1. Set "esModuleInterop": true in tsconfig.json
  2. Then the below code works:
import extractEmail from 'extract-email-address';
extractEmail('[email protected]');

edit) It seems email-addresses can be a better option.

tmokmss avatar May 30 '24 14:05 tmokmss

Fixed in v3.0.1

gajus avatar Jun 26 '24 17:06 gajus