Skip to content

fix: omit Husky from published package installs - #206

Open
Pybsama wants to merge 1 commit into
aws:mainfrom
Pybsama:codex/fix-package-postinstall-husky
Open

fix: omit Husky from published package installs#206
Pybsama wants to merge 1 commit into
aws:mainfrom
Pybsama:codex/fix-package-postinstall-husky

Conversation

@Pybsama

@Pybsama Pybsama commented Jul 30, 2026

Copy link
Copy Markdown

Issue #, if available:

Closes #205

Description of changes:

The published package currently runs postinstall: husky, but Husky is a
development dependency and is not available in a clean consumer install.

This keeps the repository's Yarn 3 contributor hook setup intact while using
Husky's documented Yarn publishing pattern:

  • pinst --disable runs before packing, so the published manifest has no
    active postinstall;
  • pinst --enable restores the source manifest after packing; and
  • a package-install smoke test packs the real artifact and installs it in an
    offline, development-dependency-free npm consumer.

The smoke test places a failing Husky guard ahead of the repository's own
node_modules/.bin, so the regression cannot pass by accidentally finding the
checkout's development dependency. It also restores the source manifest in a
finally block if packing fails.

Validation:

  • corepack yarn install --immutable
  • corepack yarn test --runInBand (25/25)
  • corepack yarn test:package-install
  • corepack yarn lint
  • corepack yarn typescript
  • corepack yarn prepare
  • real npm pack followed by offline npm and Yarn 3 consumer installs
  • corepack yarn prettier --check package.json .github/workflows/pr.yaml scripts/test-package-install.js
  • git diff --check

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@tdammy92

Copy link
Copy Markdown

@Pybsama thank you for the response, is this meant to be implemented on the project using the library or its a patch to the library itself.

I tried the fix on the Local project using the library but still got the error. however if its meant to be implementated on the library and patched, that might be a challange. how do i add the patch if its not installed in the first place. or probably i am get the whole fix wrong. more context on the implmentation will be much appreciated 🙏

@Pybsama
Pybsama force-pushed the codex/fix-package-postinstall-husky branch from 3bc8b2b to 99aee6b Compare August 29, 2026 15:21
@Pybsama

Pybsama commented Aug 29, 2026

Copy link
Copy Markdown
Author

Thanks for asking, and sorry the scope was not clear. This is a patch to the library's publishing process, not code that should be copied into an app that consumes the library.

pinst runs when the library maintainer packs or publishes a release. It disables the development-only postinstall: husky in the published tarball, then restores it in the source checkout so contributors keep their Git hooks. Once this is merged and included in a new release, consumers should only need to update to that release.

The currently published 1.6.1 package still contains postinstall: husky, so trying the PR's changes only in your app will not change that already-published tarball. As a temporary npm workaround, npm install amazon-ivs-react-native-player@1.6.1 --ignore-scripts skips the failing hook, but please note that --ignore-scripts applies to every package handled by that npm operation, so it should be reviewed for your dependency tree and is not the permanent fix.

I have now rebased this library-side patch onto 1.6.1 and revalidated both npm and Yarn consumer installs from the resulting packed artifact. The permanent resolution still requires this PR to be merged and a corrected package version to be published by the maintainers.

@Pybsama

Pybsama commented Aug 29, 2026

Copy link
Copy Markdown
Author

Revalidated and updated this PR against current main / v1.6.1 (fd360c716c5f8b4c9dd01c6ee5b80fa7a1b99f85). The two upstream commits only change the Android broadcast-receiver flag and package version; the packaging patch applies cleanly. Published head: 99aee6bdc9f2cd397f15ab318866600a65b1160f; tree: 84e27f0f4e3567bd94418dcd7cc1db0a7de3b82c.

  • The npm registry's current v1.6.1 metadata still contains postinstall: husky, so postinstall script fails when package is installed as a dependency - husky: command not found #205 remains reproducible.
  • Red/green on current main: with the two pinst lifecycle hooks removed, the CI-level yarn test command passes all 25 Jest tests and then fails the packed-consumer regression because the Husky guard is invoked (exit 86). With the fix, the full command passes. The package-install regression is now chained into yarn test, so the repository's existing test job will execute it.
  • Exact .nvmrc runtime: Node 23.11.0, npm 10.9.2, Yarn 3.6.1. Immutable install, 25/25 Jest tests, TypeScript, ESLint, targeted Prettier, and the Bob module/type build all pass.
  • The packed-install smoke passed 25 consecutive runs. A final 71-file, 39.9 kB v1.6.1 artifact has no active postinstall, restores the source manifest byte-for-byte after packing, and installs successfully into fresh offline npm and Yarn consumers with lifecycle scripts enabled.
  • npm publish --dry-run completes the prepack -> prepare -> postpack chain and restores the manifest. Public JavaScript Semgrep rules reported 0 findings across 68 rules on the changed script; git diff --check passes.

The previous run has no jobs or logs and changed to failure exactly 30 days after creation. That timing and zero-job state match GitHub's documented behavior, which automatically deletes fork workflow runs that await approval for more than 30 days. The new PR checks run is action_required with 0 jobs and awaits maintainer approval; no test job has failed. Android/iOS Detox E2E was not rerun because this change only affects package publishing and does not touch runtime code.

@Pybsama
Pybsama marked this pull request as ready for review August 29, 2026 15:25
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.

postinstall script fails when package is installed as a dependency - husky: command not found

2 participants