16

I need to install a beta version 3.0.0 of react-docgen.

Is it possible to install a beta version via npm?

KyleMit
  • 30,350
  • 66
  • 462
  • 664
Anaïs Saez
  • 1,259
  • 5
  • 20
  • 38
  • 2
    Possible duplicate of [When installing a package with NPM, can you tell it to use a different version of one of its dependencies?](https://stackoverflow.com/questions/11233133/when-installing-a-package-with-npm-can-you-tell-it-to-use-a-different-version-o) – bennygenel Sep 28 '17 at 10:19

3 Answers3

13

Yes, it's possible to install a beta version using the @ symbol. For example to install react-docgen (v3.0.0-beta7) run the following command:

npm install -g react-docgen@3.0.0-beta7

Further information about installing specific versions can be found in the npm-install documentation.

RobC
  • 22,977
  • 20
  • 73
  • 80
12

The syntax for npm install includes both of the following overloads:

npm install [<@scope>/]<name>@<tag>
npm install [<@scope>/]<name>@<version>

For tag, you can specify either @latest and @beta like this:

npm install @11ty/eleventy@latest  # latest stable release
npm install @11ty/eleventy@beta    # latest beta release

Interestingly, if you don't specify a tag, the default, set by your npm config, is @latest

You can also find out which versions are available by running npm view

npm view @11ty/eleventy

npm view

KyleMit
  • 30,350
  • 66
  • 462
  • 664
6

To install a specific beta version:

npm install -g react-docgen@3.0.0-beta7
//or
yarn global add react-docgen@3.0.0-beta7  // if you use yarn

P.S.:

In order to see all versions of a package (including alpha, beta , pre-release, release):

npm show <package> versions --json

Example:

npm show react-docgen versions --json

enter image description here


You can also install a certain version using a tag!

npm install <name>@<tag>

In order to see which tags are available for this package, you have to run:

npm view react-docgen

enter image description here

A tag can be used when installing packages as a reference to a version instead of using a specific version number (alias)

Legends
  • 21,202
  • 16
  • 97
  • 123
  • 1
    Commonly ```@next``` is NOT alias for latest beta and ```@latest``` is NOT alias for latest stable version for any arbitrary package. Real version aliases of a package can only be known via ```npm view ``` – user16547619 Aug 30 '22 at 11:49
  • You are right. In this case the distributor uses the "next" tag for the latest `alpha` version of the `react-docgen` package. I will edit my answer to make it more clear. Thank you. – Legends Aug 31 '22 at 14:11