Install specific version of a library with NPM

Asked

Viewed 7,935 times

4

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 roll npm i nome-do-package, he will install the version 1.2.0, for being the last.

But how would I install the version 1.1.0 package, since, whenever I install, comes the latest version?

2 answers

8


  • 2

    Nice, it’s very simple. Thanks for the +1 reply

  • 1

    Excellent question, will help a lot of people for sure!

6

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. To check all versions, just use:

npm view <package> versions

Source: https://docs.npmjs.com/cli/install

  • Great answer! I didn’t know the npm view.

Browser other questions tagged

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