Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: ensure husky installs correctly in production builds #617

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wthrajat
Copy link

@wthrajat wthrajat commented Oct 29, 2024

This PR addresses an issue where npm install fails due to husky not being available in production.

Reason:

Husky is only listed under devDependencies, but the prepare script (inside package.json) is still executed when we run npm install — even in production. This fails because npm skips devDependencies in production mode (NODE_ENV=production), and thus Husky isn’t installed.

In the Dockerfile, when we set NODE_ENV=production, running npm install doesn't include devDependencies. But the prepare script will still run and cause the build to fail unless dependencies like husky are available.

Solutions:

Solution 1 (this PR, the simplest solution and better because it solves the issue even for people not using Docker): Move husky from devDependencies to dependencies

Another solution: Add this to Dockerfile

RUN npm install husky --omit=optional

This ensures that even though npm ci omits devDependencies, Husky will still be available.

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.

1 participant