Skip to content

New exports field in package.json is missing require #237

@Nadreck

Description

@Nadreck

Describe the bug
When using the exports field in package.json on a package that still needs to support the older require syntax, you need to include require as one of the exports. Otherwise, you get ERR_PACKAGE_PATH_NOT_EXPORTED. Because of this, anyone using the older syntax on feed 5.2.0 is broken.

To Reproduce
Steps to reproduce the behavior:

  1. Create a file that imports the feed package using require, such as const Feed = require('feed').Feed;
  2. Attempt to run the script.
  3. See error

Expected behavior
If you update package.json to:

"exports": {
    ".": {
      "import": "./lib/feed.js",
      "require": "./lib/feed.js",
      "types": "./lib/feed.d.ts"
    }
  },

The script resumes working.

Actual behavior
The script crashes with a Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined error.

Versions (please complete the following information):

  • NodeJS: 20.19.6
  • TypeScript: n/a
  • npm/yarn: npm 11.6.3
  • feed: 5.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions