Tired of waiting for `npm install` every time you touch Docker?
It’s no secret that ‘npm install' can take a long time. An excessive amount of time, even. And Docker, for all of its tremendous benefits, seems to make the installation of node modules a regular event. In a given day, ‘npm install’ can be run dozens of times, often several times per hour when you’re working on your Dockerfile or standing up a development container.
With the complexities of today’s applications and dependency trees sitting in side of Docker, it’s easy to understand why developers think they need to run “npm install” on a regular basis.
What’s not easy to understand is how the Docker experts handle this without suffering through this npm delay constantly.
How do they stay sane and productive when it can take 2… 5… 10 minutes (or more!) to run ‘npm install', and have it run multiple times per hour?
The answer is not “switch to yarn” as some would have you believe. Nor is a cup of coffee and Netflix the right way to go. Life is too short to spend it sitting idly, waiting for your package manager to finish its work.
The truth is, the Docker experts don't deal with this npm delay nearly as often as you think. In fact, they rarely run “npm install” unless they are building a new image stack from scratch or truly adding a new dependency to their application or development process.
Instead of looking for workarounds that might help cut some time from the install, the experts know the solutions to cut the npm delay by not running “npm install” unless they absolutely must.
Now, the expert's solution for creating the ultimate node modules cache inside of Docker is readily available to everyone.
Don’t wait an eternity for Docker to run ‘npm install', only to realize you need to change your Dockerfile and rebuild the image. Or that you have to run a new container instance and re-install all of your development dependencies… again.
Take advantage of the tools you already have in Docker. Build the ultimate Node.js module cache. Cut the npm delay from your Docker projects – in most cases, eliminating it entirely! – and regain your lost productivity!