Skip to content

fix: mime.getType is not a function in CJS build (#416)#417

Merged
MrRefactoring merged 1 commit intomasterfrom
fix/416-mime-getType-commonjs
Feb 26, 2026
Merged

fix: mime.getType is not a function in CJS build (#416)#417
MrRefactoring merged 1 commit intomasterfrom
fix/416-mime-getType-commonjs

Conversation

@MrRefactoring
Copy link
Owner

Problem

When using jira.js v5.x with CommonJS (require('jira.js')), calling issueAttachments.addAttachment() fails with:

TypeError: mime.getType is not a function

The library depended on mime@^4.1.0, which is ESM-only; require('mime') in the CJS bundle does not expose .getType().

Solution

  • Replaced mime with mime-types, which works in both ESM and CJS.
  • Use mimeTypes.lookup(filename) directly in version2/issueAttachments, version3/issueAttachments, and serviceDesk/serviceDesk for MIME type detection.

Changes

Closes #416

@MrRefactoring MrRefactoring added this to the v5.3.1 milestone Feb 18, 2026
Use mime-types instead of mime for ESM/CJS compatibility. v5.3.1.
@MrRefactoring MrRefactoring force-pushed the fix/416-mime-getType-commonjs branch from c50561c to 8869b7f Compare February 18, 2026 21:09
@MrRefactoring
Copy link
Owner Author

Hi everyone 👋

I've published a dev tag with this fix so it can be tested before merging/release.

You can install and try it using:
jira.js@5.3.1-dev20260219071444

Please let me know if everything works as expected or if you notice any issues. Thanks!

@MrRefactoring MrRefactoring merged commit 6f9b560 into master Feb 26, 2026
18 of 20 checks passed
@MrRefactoring MrRefactoring deleted the fix/416-mime-getType-commonjs branch February 26, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mime.getType is not a function in v5.x when using CommonJS

1 participant