There might be situations where you want to install production dependencies only but you have npm scripts using a dev dependency command. For example it can be the case if you use the
husky package. In this blog post, we'll look how to install production-only dependencies with hooks using dev dependency.
One common problem developers face is that the commands from dev dependencies are not available when installing production dependencies. This is because npm install only production dependencies and the command used in the script uses a command from a dev dependency not installed. This can result in a "command not found" error when you attempt to use a command from a dev dependency in your project.
To overcome this issue and ensure that hooks will not be blocking when installing production dependencies, you can disable the prepare npm hook. Depending on the version of npm you are using, there are different solutions to achieve this:
Run the following command to disable the
prepare hook for all dependencies:
npm set-script prepare "" npm ci --omit=dev
This command sets an empty script for the prepare hook, effectively disabling it for all dependencies.
Run the following command to remove the
prepare hook from the
scripts section of your
npm pkg delete scripts.prepare npm ci --omit=dev
This command will remove the
scripts.prepare key from your
package.json file, ensuring that the
prepare hook is no longer executed during the installation of dependencies.
If you're seeking solutions to a problem or need expert advice, I'm here to help! Don't hesitate to book a call with me for a consulting session. Let's discuss your situation and find the best solution together.
Introducing new blog on OAuth, OpenID Connect, and IAM Solutions
I'm excited to announce the launch of a new blog named CerberAuth, where I'll be exploring the world of OAuth, OpenID Connect, and IAM solutions for modern security.
MySQL Docker Image for Mac ARM M1
MySQL official Docker image is not available for Apple ARM-based M1 and M2 CPUs. But there is some options to use mysql image on Mac and more globally on ARMv8 microarchitecture.
How to deal with Docker Hub rate limit on AWS
Since 2020, DockerHub has been limited to only 200 container image pull requests per six hours. This article will help you to deal with this limitation on AWS.