cli icon indicating copy to clipboard operation
cli copied to clipboard

[DOCS] Document how to replace a dependency with a fork with overrides.

Open everett1992 opened this issue 3 years ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This is a CLI Docs Enhancement, not another kind of Docs Enhancement.

  • [X] This is a CLI Docs Enhancement.

Description of Problem

If you need to make specific changes to dependencies of your dependencies, for example replacing the version of a dependency with a known security issue, replacing an existing dependency with a fork https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

This sounds like you can replace [email protected] with @private/[email protected] but the examples and documentation do not explain how to.

Potential Solution

If this is supported please document it, if it isn't please remove the references to replacing an existing dependency with a fork

Docs URL

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

everett1992 avatar May 17 '22 16:05 everett1992

Any update on this in the doc?

FWIW, this seems to work for me, found it on a different Github repo being used:

Note: it does not work, at least in my case, if I try limiting the version of jsonlint being matched, it only works if it's open and freeform version to override.

  "overrides": {
    "jsonlint": "npm:@prantlf/jsonlint@^11.6.0"
  },

miWatch10 avatar Jun 02 '22 13:06 miWatch10

Ran into the same confusion. In my case I needed to swap out node-sass for sass. @miWatch10's suggestion of the npm: prefix was the only thing that ended up working but it's admittedly not intuitive.

"overrides": {
  "dependency": {
    "node-sass": "npm:[email protected]",
    "sass-loader": "9.0.3"
  }
}

stephenjwatkins avatar Sep 01 '22 15:09 stephenjwatkins

One more example in case it helps out anyone else... this successfully targets a specific branch ("modernize" in this case) from a GitHub fork that's not published to NPM:

  "overrides": {
    "node-jq": {
      "bin-build": "github:brave/bin-build#modernize"
    }
  }

kitschpatrol avatar Apr 17 '23 02:04 kitschpatrol

Is there a way to override with a local file, rather than a package published to the npm registry or GitHub?

GeoffreyBooth avatar May 08 '23 18:05 GeoffreyBooth

Is there a way to override with a local file, rather than a package published to the npm registry or GitHub?

I`m interested on an answer for the question above too.

stefanlucas avatar May 19 '23 20:05 stefanlucas

https://docs.npmjs.com/cli/v9/configuring-npm/package-json

Screen Shot 2023-07-18 at 10 14 48 AM

hochoy avatar Jul 18 '23 17:07 hochoy

ditto this

"dependency with a fork" sounds pretty clear to me. So... HOW?

phillipwildhirt avatar May 07 '24 14:05 phillipwildhirt