How to pass npm flag with Cloudflare workers during install
Emmanuel Gautier / November 09, 2025
1 min read
Passing NPM Flags with Cloudflare Workers to fix installation issues
When using Cloudflare workers to build your project, you may encounter an error like Fix the upstream dependency conflict, or retry this command with --force or --legacy-peer-deps.
This error is quite generic and can be caused by many different reasons. One of them is a dependency conflict between two packages. I encountered this error when trying to install a package with a peer dependency that was not installed (next-plausible and next).
The solution is to use the legacy-peer-deps flag with npm. This flag will allow npm to install dependencies even if there are conflicts between them.
To pass this flag to npm, you need to create a .npmrc file with the following content:
legacy-peer-deps=true
Now, when you run the npm install command, it will use the legacy-peer-deps flag. This flag will also be used by Cloudflare workers or any other command that uses npm to install dependencies. This is a good way to fix installation issues with Cloudflare workers.
Consulting
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.
Related Posts
Installing Production-Only Dependencies with Dev Dependency Hooks in Node.js
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.
Read Package.json file from Node.JS module
When you write a program you may want to read the content of the package.json file like what is the current package version. Here is one very simple way to read the content of this file.
Import a JSON file content from a Node.JS module
With the new Node.JS module it is possible to read the content of a JSON file with the import function but there is the right way to do it.
Featured Posts
Introducing new blog about 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.
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.
How to enable Python type checking in VSCode
Python now has support for type hints. In this article, we will see how to enable better IntelliSense and type checking analysis in VSCode.