Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm - how to override a dependent package's dependencies?

Tags:

node.js

I have a Dev dependency in my package.json file on protractor

"protractor": "~2.1",

However protractor uses an older version of

"selenium-webdriver": "2.45.1",

I need to update this to use 2.46.1. How can I override this in my package.json file? Currently to test it out I went to /node_modules/protractor/package.json and changed it there which made. I looked at npm-shrinkwrap but that seems to lock all the packages and I just want to override a single package

like image 764
user3626708 Avatar asked Aug 27 '15 01:08

user3626708


2 Answers

For your problem you can user something called as npm shrinkwrap.

I think that is the way they explained it. Yes you are correct it locks down the dependency but, by doing so you also want same thing you want some specific dependency for your need.

Take a look at this question How do I override nested NPM dependency versions?

like image 154
Dnyanesh Avatar answered Oct 08 '22 15:10

Dnyanesh


NPM 8 introduced "overrides" which allows you to override specific transitive dependencies of your direct dependency. For your usecase, you would declare something like below.

{
  "overrides": {
    "protractor": {
      "selenium-webdriver": "2.46.1"
    }
  }
}

More details @ https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

like image 30
Sateesh Avatar answered Oct 08 '22 15:10

Sateesh