Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 397 Vote(s) - 3.56 Average
  • 1
  • 2
  • 3
  • 4
  • 5
When installing a package with NPM, can you tell it to use a different version of one of its dependencies?

#1
Say you want to install a library `lib-a` which has dependencies `dep-1` and `dep-2`. If `lib-a` has declared in its package.json to use a version of `dep-2` that is out of date (say it doesn't work on node 0.8.0 which just came out), but there is a branch of `dep-2` that works with node 0.8.0 - branch name `node0.8.0`.

So the packages in the equation are:

git://github.com/user-a/lib-a
git://github.com/user-b/dep-1
git://github.com/user-c/dep-2
git://github.com/user-c/dep-2#node0.8.0

Is there a way to tell NPM to install `lib-a`, but use `dep-2#node0.8.0` instead of `dep-2`?

With NPM you can install a specific branch of a project like this:

npm install git://github.com/user-c/dep-2#node0.8.0

And if I were to customize the package.json of `lib-a`, you could tell it to use `dep-2#node0.8.0` like this:

{
"name": "lib-a",
"dependencies": {
"dep-1": ">= 1.5.0",
"dep-2": "git://github.com/user-c/dep-2#node0.8.0"
}
}

By modifying the package.json you can then run

npm install lib-a

and it will install the node 0.8.0 compatible `dep-2` branch. But, that requires I have access to modifying `lib-a`, which for my specific case I don't. Technically, I could fork `lib-a` and make the above change to package.json. But in my specific case, `lib-a` is a dependency of _another_ library, so I'd have to fork the project it's referenced in, and on and on...

So the question is, is there a way to tell NPM to install `lib-a`, and tell it to use the `node0.8.0` branch of `dep-2`? Something like this:

npm install lib-a --overrides dep-2:git://github.com/user-c/dep-2#node0.8.0

That would be awesome. If it's not possible, that would be good to know so I can prepare myself to have to fork/customize the chain of projects.
Reply

#2
**NPM install syntax:**

npm install (with no args in a package dir)
npm install <tarball file>
npm install <tarball url>
npm install <folder>
npm install [@<scope>/]<name> [--save|--save-dev|--save-optional] [--save-exact]
npm install [@<scope>/]<name>@<tag>
npm install [@<scope>/]<name>@<version>
npm install [@<scope>/]<name>@<version range>
npm i (with any of the previous argument usage)

so you can choose one of these methods to install your modules.

The case of the simplest way to install a specific version is this one:

npm install [email protected]

more info:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through