muratgozel / MIMEText

RFC-2822, RFC-2045 and RFC-2049 compliant raw email message generator.
https://muratgozel.github.io/MIMEText/
MIT License
82 stars 35 forks source link

CJS version of `mimetext@3.0.19`+ can't be imported, ESM issues #63

Closed s100 closed 8 months ago

s100 commented 9 months ago

Do the following:

npm install mimetext
node
require('mimetext')

And I see:

var _MIMEMessage = require("../MIMEMessage.js");
                   ^
Uncaught:
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\...\node_modules\mimetext\build\MIMEMessage.js from C:\...\Downloads\node_modules\mimetext\build\entrypoints\node.cjs not supported.
Instead change the require of MIMEMessage.js in C:\...\Downloads\node_modules\mimetext\build\entrypoints\node.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (C:\...\Downloads\node_modules\mimetext\build\entrypoints\node.cjs:42:20)
    at REPL1:1:1
    at Script.runInThisContext (node:vm:123:12)
    at REPLServer.defaultEval (node:repl:569:29)
    at bound (node:domain:433:15)
    at REPLServer.runBound [as eval] (node:domain:444:12)
    at REPLServer.onLine (node:repl:899:10)
    at REPLServer.emit (node:events:526:35)
    at REPLServer.emit (node:domain:489:12)
    at REPLServer.self._ttyWrite (node:repl:994:9)
    at ReadStream.emit (node:events:514:28)
    at ReadStream.emit (node:domain:489:12)
    at emitKeys.next (<anonymous>)
    at ReadStream.emit (node:events:514:28)
    at ReadStream.emit (node:domain:489:12) {
  code: 'ERR_REQUIRE_ESM'
}

Seems as if build/entrypoints/node.cjs is requireing build/MIMEMessage.js when it should be requireing build/MIMEMessage.cjs.

mimetext@3.0.18 worked.

muratgozel commented 8 months ago

hey, what is your node version?

s100 commented 8 months ago

18.17.1.

esakkirajaravenantech commented 8 months ago

we have the same problem, using node version v19.9.0, we need help

Nexus-coder commented 8 months ago

Have the same problem as this how do i fix?

s100 commented 8 months ago

Current workaround is to pin to mimetext@3.0.18.

Nexus-coder commented 8 months ago

Thanks its worked

esakkirajaravenantech commented 8 months ago

Thanks. Its worked.

muratgozel commented 8 months ago

all typings should be working as of v3.0.23, closing this issue for now.