Skip to content

badge-maker: fix exports so that it can also be required #11181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025

Conversation

vidarc
Copy link
Contributor

@vidarc vidarc commented Jun 20, 2025

Requiring ESM was ported back to version 20.19.0 of NodeJS, so this PR fixes the exports field so that you can do so. Only requirement is that there is no top-level await for it to work, which doesn't look like this package relies on anyway.

before

Welcome to Node.js v20.19.2.
Type ".help" for more information.
> require('badge-maker')
Uncaught:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /.../node_modules/badge-maker/package.json
    at exportsNotFound (node:internal/modules/esm/resolve:322:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:613:13)
    at resolveExports (node:internal/modules/cjs/loader:636:36)
    at Module._findPath (node:internal/modules/cjs/loader:716:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1198:27)
    at Module._load (node:internal/modules/cjs/loader:1043:27)
    at Module.require (node:internal/modules/cjs/loader:1298:19)
    at require (node:internal/modules/helpers:182:18) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

after

Welcome to Node.js v20.19.2.
Type ".help" for more information.
> require('badge-maker')
[Module: null prototype] {
  ValidationError: [class ValidationError extends Error],
  makeBadge: [Function: makeBadge]
}

Copy link
Contributor

Messages
📖 ✨ Thanks for your contribution to Shields, @vidarc!

Generated by 🚫 dangerJS against 93344db

Copy link
Member

@jNullj jNullj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix.
for anyone looking for docs about this - link, link, link.

@jNullj jNullj added this pull request to the merge queue Jun 20, 2025
Merged via the queue into badges:master with commit 3c23de5 Jun 20, 2025
19 checks passed
@jNullj jNullj added the npm-package Badge-maker NPM package label Jun 20, 2025
@vidarc vidarc deleted the require-esm branch June 21, 2025 01:40
@jNullj
Copy link
Member

jNullj commented Jun 21, 2025

@vidarc fix is now live on npm with ver 5.0.2, enjoy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
npm-package Badge-maker NPM package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants