You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
Activity
test: include npm package.json fixture for dlang#3118
AMDphreak commentedon Jul 25, 2026
Additional reproduction from a mixed Node+D monorepo (
dev-centr/devcentr): root Antora/npmpackage.jsonwithprivate/devDependencies/packageManager, while the Dub recipe lives inapp/dub.json. Runningdub buildat 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
fix: refuse to load npm package.json files
test: include npm package.json fixture for dlang#3118
test: convert dlang#3118 test to the in-tree unittest framework
test: include npm package.json fixture for #3118
test: convert #3118 test to the in-tree unittest framework
fix: refuse to load npm package.json files