Thursday, 25 October 2018

How to prevent an unused npm dependency to be installed?

So in my project, I require multiple packages, including "dep1".

"dep1" requires another dependency, "dep2".

And "dep2" requires multiple packages, including "dep3".

The problem is, "dep3" is not compatible with the licence I want to use (well actually, with the licence my boss wants to use).

Fortunatly, only one function of "dep2" uses "dep3", and "dep1" does not use this function. So if I remove "dep3" from node_modules, all will go smoothly.

The problem I have is, how to modify package.json to take this into account when doing npm install, and not install this package ?

I am aware I could branch "dep2" to supress the function, and then "dep1" to use the modifies "dep2", but this seems overkill, and I would be dependant of the owner of the packages to accept my branch. I am looking for a solution like 'well, just add the line ignore : "dep3" into package.json', but can't find any.

Thanks for your help !



from How to prevent an unused npm dependency to be installed?

No comments:

Post a Comment