How do I update my package dependencies without publishing a new version of my package?

Asked

Viewed 187 times

0

I am developing a package that is dependent on other packages.
What I wanted to know is if there is a form of the package I am developing already download the latest version of the packages without I need to update the publication in npm.

For example, let’s say I have package A 1.0 and package B 1.0, my package B depends on package A and package A has been upgraded to version 1.1, is there a way that when I install package B 1.0, it pulls package A 1.1? Or I need to release a B package update whenever there are updates on the packages it depends on?

  • If the package is yours, just inform on package json. that you want the latest version (even though you know it might break your application) of the dependencies, using *.

1 answer

2


In your example where the package [email protected] package-dependent [email protected] the package.json file of the package B should look like the following:

{
  "name": "B",
  "version": "1.0.0",
  "dependencies": {
    "A": "1.0.0"
  }
}

To get the last minor release of the package [email protected] when installing the package [email protected] just add the prefix ^ in the version:

{
  "name": "B",
  "version": "1.0.0",
  "dependencies": {
    "A": "^1.0.0"
  }
}

To get the last package patch [email protected] when installing the package [email protected] just add the prefix ~ in the version:

{
  "name": "B",
  "version": "1.0.0",
  "dependencies": {
    "A": "~1.0.0"
  }
}

If you always want to get the latest version of the package A folder use the latest instead of the version number ("A": "latest").

Browser other questions tagged

You are not signed in. Login or sign up in order to post.