Skip to content

Refuse to load npm package.json files #3118

Closed

Description

@vpanteleev-sym

For historic reasons, Dub may attempt to load package.json files (older name for dub.json). However, npm uses this file name too.

When Dub can't find a dub.json file but finds a package.json file belonging to npm, it will still attempt to load it. Because Dub ignores unknown fields in the file, and there is sufficient overlap between the two formats that Dub may try to make sense of the declarations therein, it can lead to very confusing messages.

Proposal: when Dub detects top-level keys which are used by npm but not Dub, raise a hard error and refuse to parse the file completely. Some keys we can use for this are packageManager, scripts, devDependencies, and workspaces.

Activity

  1. AMDphreak commented on Jul 25, 2026

    @AMDphreak
    Contributor

    Additional reproduction from a mixed Node+D monorepo (dev-centr/devcentr): root Antora/npm package.json with private / devDependencies / packageManager, while the Dub recipe lives in app/dub.json. Running dub build at the repo root produced unknown-key warnings and then failed as an empty library / targetType: none.

    Opened a PR implementing the sentinel-key refusal: #3136

  2. added 3 commits that reference this issue on Nov 6, 2026
    3509e6c
    b8fa23d
    0450e1e
  3. added a commit that references this issue on Nov 6, 2026
  4. added a commit that references this issue on Nov 7, 2026
    f890c49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions