Install specific version of a library with NPM

3

How do I choose the version of a library I want to use with NPM?

For example

1.0.0
1.0.1
1.1.0
1.1.1
1.2.0

If I run npm i nome-do-package , it will install the 1.2.0 version, because it is the last one.

But how would I install the version 1.1.0 of the package, since, whenever I install, does the latest version come?

    
asked by anonymous 05.01.2017 / 12:58

2 answers

7

You can use @ to specify the version, like this:

npm i [email protected]
    
05.01.2017 / 13:02
5

The command below allows you to install a specific version of a package .

npm install <package>@<version>

Ex: npm install [email protected]

It may fail if the version has not been published in the package registry. To check all versions, just use:

npm view <package> versions

Source: link

    
05.01.2017 / 13:10