DEV Community

Cover image for Install a specific version of a dependency for Npm, Pip, Gem, and more
Cédric Teyton for Packmind

Posted on

Install a specific version of a dependency for Npm, Pip, Gem, and more

Package managers are commonly used in software development in order to benefit from existing dependencies such as open-source libraries. npm is our favorite tool at Promyze. While developers often use associated manifest files to list external dependencies, they can also use the command line version to install a dependency. Common questions in such cases: how to install a specific version of a library? Should we use symbols such '@', '^', '=' or something else?

This post is a quick reminder for how to achieve that for several package managers.

APK (Alpine)

apk add mysql-client=10.5.11-r0
Enter fullscreen mode Exit fullscreen mode

APT (Ubuntu/Debian)

apt-get install mysql-client=8.0.19-0ubuntu5
Enter fullscreen mode Exit fullscreen mode

Composer (PHP)

composer require amphp/mysql:2.1.0
Enter fullscreen mode Exit fullscreen mode

Gem (Ruby)

gem install mysql -v 2.9.0
Enter fullscreen mode Exit fullscreen mode

Go Modules (Go)

go get -u github.com/go-sql-driver/mysql@v1.6.0
Enter fullscreen mode Exit fullscreen mode

Npm (JavaScript/Typescript)

npm install mysql@2.18.1
Enter fullscreen mode Exit fullscreen mode

Nuget (.NET)

nuget install MySql.Data -Version 8.0.26
Enter fullscreen mode Exit fullscreen mode

Pip (Python)

pip install mysqlclient==1.4.0
Enter fullscreen mode Exit fullscreen mode

Yarn (JavaScript/Typescript)

yarn add mysql@2.18.1
Enter fullscreen mode Exit fullscreen mode

Feel free to comment to add your suggestions, we'd be glad to update the post !

Top comments (0)