Skip installing npm dependencies when deploying to Cloudflare Pages
Cloudflare is a great service for hosting any site. Be it a static site or a dynamic one, Cloudflare has got you covered. Cloudflare Pages, in particular, is a great way to deploy your static sites. It’s fast, reliable, and most importantly, it’s free. This blog is even hosted on Cloudflare Pages.
While deploying a static site to Cloudflare Pages is a breeze, there’s one thing that I found a bit annoying. That is the installation of npm dependencies. This is especially evident when you just want to deploy a static site and you don’t need any npm dependencies to be installed. But Cloudflare Pages, by default, installs npm dependencies for you if it finds a package.json
file in your repository.
This is the exact issue Jason McCreary recently faced and after some digging, he found a way to skip installing npm dependencies when deploying to Cloudflare Pages. Here’s how you can do it.
Essentially, you need to set
SKIP_DEPENDENCY_INSTALL
to1
in your Cloudflare Pages environment variables for that application. This will tell Cloudflare Pages to skip the installation of npm dependencies (or any other dependencies for that matter).
Once you set this environment variable, Cloudflare Pages will skip the installation of npm dependencies and will deploy your site without any issues. This is a great way to speed up your deployments if you don’t need npm dependencies to be installed.
Like this article?
Buy me a coffee👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.