Skip to content

fix(pkg): declare bin without a "./" prefix - #55

Merged
murffious merged 2 commits into
mainfrom
fix/46-bin-no-dot-slash
Sep 20, 2026
Merged

murffious merged 2 commits into
mainfrom
fix/46-bin-no-dot-slash

Conversation

@murffious

Copy link
Copy Markdown
Contributor

Closes #46.

Nothing was ever removed

@npmcli/package-json/lib/normalize.js, the code that emits the warning:

const binTarget = secureAndUnixifyPath(pkg.bin[binKey])   // "./bin/rainfall.js" -> "bin/rainfall.js"
...
if (binTarget !== pkg.bin[binKey]) {
  changes?.push(`"bin[${base}]" script name ${binTarget} was invalid and removed`)
}
pkg.bin[base] = binTarget                                  // assigned, not deleted

The line after the message assigns the corrected value. The three branches that genuinely drop a bin are all above it and all say removed invalid "bin[...]" — none of them fired here.

So the message is inaccurate twice over: it says removed for what is a rewrite, and it prints the corrected path as the thing that "was invalid". That is why it never matched the declared value and read as unexplained.

The registry confirms it — 0.3.2 and 0.4.0 both published with "bin": {"rainfall": "bin/rainfall.js"} intact.

Why fix it anyway

The wording is shape-identical to the warnings that do drop a bin. Leaving it printing on every release is exactly the noise that hides a real one later — and this package has shipped three versions that could not be imported while the suite was green.

Change

  • package.json: "rainfall": "bin/rainfall.js" (was "./bin/rainfall.js")
  • __tests__/package.test.js: fails if any bin target regains the prefix

exports is deliberately untouched — Node's spec requires ./ there. The guard targets bin only.

Verification

Check Result
npm publish --dry-run before warns "bin[rainfall]" script name ... invalid and removed
npm publish --dry-run after no warnings at all
npm pkg fix on the old manifest changes this one line and nothing else
Isolated A/B repro (./ vs plain) prefix is the sole cause
New test with prefix restored fails (1 failed, 8 passed)
New test as shipped passes (9 passed)
npm pack → install into clean project .bin/rainfall -> ../@morf_engineering/rainfalljs/bin/rainfall.js, rainfall components runs

No version bump: the published metadata is already the normalised form, so this changes nothing for consumers. It rides the next release.

🤖 Generated with Claude Code

murffious and others added 2 commits September 20, 2026 00:29
npm normalises every bin value through secureAndUnixifyPath. The leading
"./" made the normalised path differ from the declared one, so every
publish printed a warning whose wording matches the ones that really do
drop a bin. Nothing was ever removed. Closes #46.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Verified by restoring the prefix and watching the suite fail.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@murffious
murffious merged commit e7bed66 into main Sep 20, 2026
1 check passed
@murffious
murffious deleted the fix/46-bin-no-dot-slash branch September 20, 2026 06:30
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.

npm reports it removed the bin entry on publish (cosmetic today, unexplained)

1 participant