Problem
The package fails to install as a dependency in downstream projects due to the postinstall script attempting to run husky, which is only available in devDependencies.
Error
error /path/to/node_modules/amazon-ivs-react-native-player: Command failed.
Exit code: 127
Command: husky
Arguments:
Directory: /path/to/node_modules/amazon-ivs-react-native-player
Output:
Exit code 127 indicates "command not found" - when this package is installed as a dependency in another project, husky is not available because it's only listed in devDependencies.
Root Cause
In package.json, there's a postinstall script:
"scripts": {
"postinstall": "husky"
}
This script runs during yarn install or npm install for any project that depends on this package, but husky is only needed for contributors developing this package itself.
Expected Behavior
The package should install successfully as a dependency without requiring dev tooling like husky.
Steps to Reproduce
- Create a new React Native project
- Run
yarn add amazon-ivs-react-native-player@1.6.0
- Observe the postinstall script failure
Suggested Fix
Husky's postinstall script should only run during development, not when the package is consumed as a dependency. Consider one of these approaches:
Option 1: Remove postinstall entirely (recommended for published packages)
"scripts": {
"prepare": "husky"
}
The prepare script runs during npm install in the source directory but not when installed as a dependency.
Option 2: Use conditional execution
"scripts": {
"postinstall": "node -e \"try{require('husky')}catch(e){}\""
}
Option 3: Move to prepare script with better-sqlite3 pattern
"scripts": {
"prepare": "node -e \"try{require('husky')}catch(e){if(e.code!=='MODULE_NOT_FOUND')throw e}\""
}
Environment
- Package version: 1.6.0
- Node version: (varies)
- Package manager: Yarn 3.x / npm
Problem
The package fails to install as a dependency in downstream projects due to the
postinstallscript attempting to runhusky, which is only available indevDependencies.Error
Exit code 127 indicates "command not found" - when this package is installed as a dependency in another project,
huskyis not available because it's only listed indevDependencies.Root Cause
In
package.json, there's a postinstall script:This script runs during
yarn installornpm installfor any project that depends on this package, buthuskyis only needed for contributors developing this package itself.Expected Behavior
The package should install successfully as a dependency without requiring dev tooling like
husky.Steps to Reproduce
yarn add amazon-ivs-react-native-player@1.6.0Suggested Fix
Husky's postinstall script should only run during development, not when the package is consumed as a dependency. Consider one of these approaches:
Option 1: Remove postinstall entirely (recommended for published packages)
The
preparescript runs duringnpm installin the source directory but not when installed as a dependency.Option 2: Use conditional execution
Option 3: Move to prepare script with better-sqlite3 pattern
Environment