Table of Contents
- Introduction
- System Package Managers
- Language-Specific Package Managers
- Container and Virtualization Tools
- Development Environment Setup
- IDE and Editor Installation
- Version Control and Collaboration Tools
- Database and Infrastructure Tools
- Security and Best Practices
- Troubleshooting Common Issues
Introduction
Package management is the backbone of modern software development. Whether you're setting up a new development environment, installing dependencies for a project, or managing system-level tools, understanding how to effectively download and install packages is crucial for every developer.
This comprehensive guide covers everything from system-level package managers to language-specific tools, ensuring you have the knowledge to set up and maintain robust development environments across different platforms.
System Package Managers
Windows Package Managers
Chocolatey
Chocolatey is the most popular package manager for Windows, offering a vast repository of software packages.
Installation:
# Run PowerShell as Administrator
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Common Commands:
# Install a package
choco install git
# Install multiple packages
choco install git nodejs python3 vscode
# Update all packages
choco upgrade all
# Search for packages
choco search nodejs
# List installed packages
choco list --local-only
Windows Package Manager (winget)
Microsoft's official package manager, built into Windows 10/11.
Usage:
# Install a package
winget install Git.Git
# Search for packages
winget search "visual studio code"
# List installed packages
winget list
# Update packages
winget upgrade --all
Scoop
A lightweight package manager focusing on command-line tools.
Installation:
# In PowerShell
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
irm get.scoop.sh | iex
Usage:
# Install packages
scoop install git python nodejs
# Add buckets for more packages
scoop bucket add extras
scoop install vscode
macOS Package Managers
Homebrew
The de facto standard package manager for macOS.
Installation:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Common Commands:
# Install packages
brew install git node python3
# Install GUI applications
brew install --cask visual-studio-code google-chrome docker
# Update Homebrew
brew update
# Upgrade packages
brew upgrade
# Search for packages
brew search nodejs
# List installed packages
brew list
MacPorts
An alternative package manager for macOS with a focus on source compilation.
Installation:
Download the installer from macports.org
Usage:
# Update ports tree
sudo port selfupdate
# Install packages
sudo port install git +universal
sudo port install python39
# Search packages
port search python
Linux Package Managers
Debian/Ubuntu (APT)
# Update package list
sudo apt update
# Install packages
sudo apt install git nodejs npm python3 python3-pip
# Install specific versions
sudo apt install python3.9
# Remove packages
sudo apt remove package-name
# Search packages
apt search nodejs
# Show package information
apt show git
RedHat/CentOS/Fedora (YUM/DNF)
# Fedora (DNF)
sudo dnf update
sudo dnf install git nodejs npm python3 python3-pip
# CentOS/RHEL (YUM)
sudo yum update
sudo yum install git nodejs npm python3 python3-pip
# Enable additional repositories
sudo dnf install epel-release
Arch Linux (Pacman)
# Update system
sudo pacman -Syu
# Install packages
sudo pacman -S git nodejs npm python python-pip
# Search packages
pacman -Ss nodejs
# Remove packages
sudo pacman -R package-name
Language-Specific Package Managers
Node.js and JavaScript
npm (Node Package Manager)
# Install Node.js (includes npm)
# Windows: choco install nodejs
# macOS: brew install node
# Ubuntu: sudo apt install nodejs npm
# Initialize a new project
npm init
# Install packages locally
npm install express
npm install --save-dev jest
# Install packages globally
npm install -g typescript @angular/cli create-react-app
# Update packages
npm update
# Check outdated packages
npm outdated
# Install from package.json
npm install
Yarn
# Install Yarn
npm install -g yarn
# or
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
# Initialize project
yarn init
# Add dependencies
yarn add express
yarn add --dev jest
# Install dependencies
yarn install
# Update dependencies
yarn upgrade
pnpm
# Install pnpm
npm install -g pnpm
# Install dependencies
pnpm install
# Add dependencies
pnpm add express
pnpm add -D jest
Python
pip (Python Package Installer)
# Install pip (usually comes with Python)
python -m ensurepip --upgrade
# Install packages
pip install requests numpy pandas django
# Install from requirements file
pip install -r requirements.txt
# Install in development mode
pip install -e .
# Update packages
pip install --upgrade package-name
# List installed packages
pip list
# Show package information
pip show requests
# Create requirements file
pip freeze > requirements.txt
pipenv
# Install pipenv
pip install pipenv
# Create virtual environment and install packages
pipenv install requests
# Install development dependencies
pipenv install pytest --dev
# Activate virtual environment
pipenv shell
# Install from Pipfile
pipenv install
Poetry
# Install Poetry
curl -sSL https://install.python-poetry.org | python3 -
# Initialize new project
poetry new my-project
cd my-project
# Add dependencies
poetry add requests
poetry add --group dev pytest
# Install dependencies
poetry install
# Activate virtual environment
poetry shell
conda/Miniconda
# Install Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
# Create environment
conda create -n myenv python=3.9
# Activate environment
conda activate myenv
# Install packages
conda install numpy pandas matplotlib
conda install -c conda-forge package-name
# List environments
conda env list
# Export environment
conda env export > environment.yml
# Create from environment file
conda env create -f environment.yml
Java
Maven
# Install Maven
# Windows: choco install maven
# macOS: brew install maven
# Ubuntu: sudo apt install maven
# Create new project
mvn archetype:generate -DgroupId=com.example -DartifactId=my-app
# Install dependencies
mvn install
# Compile project
mvn compile
# Run tests
mvn test
Gradle
# Install Gradle
# Windows: choco install gradle
# macOS: brew install gradle
# Ubuntu: sudo apt install gradle
# Initialize new project
gradle init
# Build project
gradle build
# Run tests
gradle test
# Install dependencies (automatic with build)
gradle build
Ruby
RubyGems
# Install gems
gem install rails sinatra
# Install from Gemfile
bundle install
# Update gems
gem update
# List installed gems
gem list
Bundler
# Install Bundler
gem install bundler
# Initialize Gemfile
bundle init
# Install dependencies
bundle install
# Update dependencies
bundle update
Go
Go Modules
# Initialize module
go mod init example.com/myproject
# Add dependencies
go get github.com/gin-gonic/gin
# Install dependencies
go mod download
# Update dependencies
go get -u all
# Tidy modules
go mod tidy
Rust
Cargo
# Install Rust (includes Cargo)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Create new project
cargo new my-project
cd my-project
# Build project
cargo build
# Run project
cargo run
# Add dependencies (edit Cargo.toml)
# [dependencies]
# serde = "1.0"
# Install dependencies
cargo build
Container and Virtualization Tools
Docker
# Install Docker
# Ubuntu
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Windows: choco install docker-desktop
# macOS: brew install --cask docker
# Basic commands
docker pull ubuntu:20.04
docker run -it ubuntu:20.04 /bin/bash
docker build -t myapp .
docker-compose up -d
Kubernetes Tools
# Install kubectl
# macOS: brew install kubectl
# Windows: choco install kubernetes-cli
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# Install Minikube
# macOS: brew install minikube
# Windows: choco install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
Virtual Machines
# Install VirtualBox
# Windows: choco install virtualbox
# macOS: brew install --cask virtualbox
# Ubuntu: sudo apt install virtualbox
# Install Vagrant
# Windows: choco install vagrant
# macOS: brew install --cask vagrant
# Ubuntu: sudo apt install vagrant
Development Environment Setup
Version Managers
Node Version Manager (nvm)
# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# Install and use Node versions
nvm install 18
nvm install 16
nvm use 18
nvm alias default 18
Python Version Manager (pyenv)
# Install pyenv
curl https://pyenv.run | bash
# Install Python versions
pyenv install 3.9.0
pyenv install 3.10.0
pyenv global 3.10.0
pyenv local 3.9.0
Ruby Version Manager (rbenv)
# Install rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
# Install Ruby versions
rbenv install 3.0.0
rbenv global 3.0.0
rbenv local 2.7.0
Terminal and Shell Enhancement
Oh My Zsh
# Install Oh My Zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Install plugins
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
PowerShell Core
# Install PowerShell
# Windows: choco install pwsh
# macOS: brew install --cask powershell
# Ubuntu: sudo apt install -y powershell
IDE and Editor Installation
Visual Studio Code
# Windows: choco install vscode
# macOS: brew install --cask visual-studio-code
# Ubuntu:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
sudo apt update && sudo apt install code
JetBrains IDEs
# Install IntelliJ IDEA
# Windows: choco install intellijidea-community
# macOS: brew install --cask intellij-idea-ce
# Ubuntu: sudo snap install intellij-idea-community --classic
# Install PyCharm
# Windows: choco install pycharm-community
# macOS: brew install --cask pycharm-ce
Vim/Neovim
# Install Vim
sudo apt install vim # Ubuntu
brew install vim # macOS
choco install vim # Windows
# Install Neovim
sudo apt install neovim # Ubuntu
brew install neovim # macOS
choco install neovim # Windows
Version Control and Collaboration Tools
Git
# Install Git
# Windows: choco install git
# macOS: brew install git
# Ubuntu: sudo apt install git
# Configure Git
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
# Install Git LFS
git lfs install
GitHub CLI
# Install GitHub CLI
# Windows: choco install gh
# macOS: brew install gh
# Ubuntu:
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update && sudo apt install gh
# Authenticate
gh auth login
Database and Infrastructure Tools
Database Clients
# PostgreSQL
# Windows: choco install postgresql
# macOS: brew install postgresql
# Ubuntu: sudo apt install postgresql postgresql-contrib
# MySQL
# Windows: choco install mysql
# macOS: brew install mysql
# Ubuntu: sudo apt install mysql-server
# MongoDB
# Windows: choco install mongodb
# macOS: brew tap mongodb/brew && brew install mongodb-community
# Ubuntu: Follow MongoDB official installation guide
# Redis
# Windows: choco install redis-64
# macOS: brew install redis
# Ubuntu: sudo apt install redis-server
Cloud CLI Tools
# AWS CLI
# Windows: choco install awscli
# macOS: brew install awscli
pip install awscli
# Azure CLI
# Windows: choco install azure-cli
# macOS: brew install azure-cli
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# Google Cloud SDK
# Download from cloud.google.com/sdk
# macOS: brew install --cask google-cloud-sdk
Infrastructure as Code
# Terraform
# Windows: choco install terraform
# macOS: brew tap hashicorp/tap && brew install terraform
wget https://releases.hashicorp.com/terraform/1.3.0/terraform_1.3.0_linux_amd64.zip
# Ansible
pip install ansible
# Pulumi
curl -fsSL https://get.pulumi.com | sh
Security and Best Practices
Package Security
Audit Dependencies
# npm audit
npm audit
npm audit fix
# pip security check
pip-audit
# Yarn audit
yarn audit
yarn audit --level high
# Go vulnerability check
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
Use Package Locks
Always commit lock files to ensure reproducible builds:
-
package-lock.json
(npm) -
yarn.lock
(Yarn) -
Pipfile.lock
(pipenv) -
poetry.lock
(Poetry) -
go.sum
(Go modules)
Verify Package Integrity
# npm
npm config set fund false
npm config set audit-level high
# pip
pip install --require-hashes -r requirements.txt
# Use official repositories only
# Avoid installing from unknown sources
Environment Management
Use Virtual Environments
# Python
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
# Node.js
nvm use 16
# Java
sdk install java 11.0.12-open
sdk use java 11.0.12-open
Environment Variables
# Create .env files for sensitive data
echo "DATABASE_URL=postgresql://localhost/mydb" > .env
# Use tools like direnv
# Ubuntu: sudo apt install direnv
# macOS: brew install direnv
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
Troubleshooting Common Issues
Permission Issues
# Fix npm permissions (avoid sudo)
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
# Fix pip permissions
pip install --user package-name
# Use virtual environments to avoid system-wide installations
Network and Proxy Issues
# Configure npm for proxy
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
# Configure pip for proxy
pip install --proxy http://proxy.company.com:8080 package-name
# Configure git for proxy
git config --global http.proxy http://proxy.company.com:8080
Version Conflicts
# Use specific versions
npm install package-name@1.2.3
pip install package-name==1.2.3
# Check installed versions
npm list
pip list
go list -m all
# Clean cache when issues arise
npm cache clean --force
pip cache purge
go clean -modcache
Disk Space Issues
# Clean package caches
npm cache clean --force
yarn cache clean
pip cache purge
go clean -cache -modcache
# Remove unused packages
npm prune
pip-autoremove
Best Practices Summary
- Use Package Managers: Always prefer package managers over manual downloads
- Version Control: Pin dependency versions for production applications
- Security First: Regularly audit and update dependencies
- Environment Isolation: Use virtual environments and containers
- Documentation: Maintain clear documentation of dependencies and setup steps
- Automation: Use scripts and CI/CD for consistent setups
- Backup Configurations: Store dotfiles and configurations in version control
- Stay Updated: Keep package managers and tools updated
- Test Changes: Always test dependency updates in staging environments
- Monitor Dependencies: Use tools to track outdated and vulnerable packages
This guide provides a comprehensive foundation for managing packages and tools across different development environments. Remember that the landscape of package management is constantly evolving, so staying updated with the latest best practices and tools is essential for effective development workflow management.
Top comments (0)