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

Allow preventing on installation of dependancy using overrides. #7907

Open
1 task
kristian-puccio opened this issue Apr 12, 2024 · 2 comments
Open
1 task

Comments

@kristian-puccio
Copy link

Contribution

Describe the user story

I'm trying to fix an audit issue and would like to prevent a sub dependency from installing the package "request".

I've tried doing things like patching the package.json of the sub dependency to remove the problem package but it runs too late and the package has already been installed.

I've tried setting in the pnpm.overrides the package version to be either null or false but that causes pnpm i to fail.
I've also tried setting the version to 0.0.0 but pnpm complains and asks me to install a valid version.

Describe the solution you'd like

Allow using false as the version of the package in overrides to skip installing that dependancy.

"pnpm": {
"overrides": {
"request": false
}
}
}```

### Describe the drawbacks of your solution

You may get yourself in trouble if that package ends up being used, but you probably shouldn't mess with overrides unless you know what you are doing.

### Describe alternatives you've considered

null instead of false could work, I don't have an opinion either way.
@zkochan
Copy link
Member

zkochan commented Apr 12, 2024

You can remove it using a read package hook in .pnpmfile.cjs: https://pnpm.io/pnpmfile#hooksreadpackagepkg-context-pkg--promisepkg

@kristian-puccio
Copy link
Author

Nice thanks, would be easier to just do it in overrides but this works.
Shall I close the ticket?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants