CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-yarn

Fast, reliable, and secure dependency management tool for JavaScript/Node.js projects

Overview
Eval results
Files

configuration.mddocs/

Configuration

Commands for managing yarn configuration, global packages, and development symlinks.

Capabilities

Configuration Management

Manage yarn configuration settings at global and project levels.

yarn config set <key> <value> [options]    # Set configuration value
yarn config get <key>                      # Get configuration value
yarn config delete <key> [options]         # Delete configuration key
yarn config list                           # List all configuration
yarn config current                        # Show current effective configuration

# Options:
--global, -g             # Set global configuration (user-level)

Usage Examples:

# Set configuration values
yarn config set registry https://registry.npmjs.org
yarn config set cache-folder /tmp/yarn-cache
yarn config set network-timeout 300000

# Set global configuration
yarn config set registry https://npm.company.com --global
yarn config set ignore-engines true --global

# Get configuration values
yarn config get registry
yarn config get cache-folder

# List all configuration
yarn config list

# Show current effective configuration with sources
yarn config current

# Delete configuration
yarn config delete registry
yarn config delete network-timeout --global

Common Configuration Options

# Registry settings
yarn config set registry <url>                    # Default package registry
yarn config set <scope>:registry <url>            # Registry for scoped packages

# Cache settings  
yarn config set cache-folder <path>               # Cache directory location
yarn config set offline-mirror <path>             # Offline cache location

# Network settings
yarn config set network-timeout <ms>              # Network request timeout
yarn config set network-concurrency <number>      # Concurrent network requests

# Installation behavior
yarn config set ignore-scripts <boolean>          # Skip lifecycle scripts
yarn config set ignore-engines <boolean>          # Ignore engines field
yarn config set ignore-platform <boolean>         # Ignore platform checks
yarn config set flat <boolean>                    # Use flat dependency structure

# Workspace settings
yarn config set workspaces-experimental <boolean> # Enable workspace features

Configuration Examples:

# Corporate environment setup
yarn config set registry https://npm.company.com
yarn config set //npm.company.com/:_authToken ${NPM_TOKEN}
yarn config set strict-ssl false

# Development optimizations
yarn config set network-timeout 600000
yarn config set network-concurrency 16
yarn config set cache-folder ~/.yarn-cache

# Security settings
yarn config set ignore-scripts true
yarn config set audit-level moderate

Global Package Management

Manage globally installed packages.

yarn global add <package> [options]        # Install global package
yarn global remove <package>               # Remove global package
yarn global list [options]                 # List global packages
yarn global upgrade [package] [options]    # Upgrade global packages
yarn global bin                            # Show global bin directory

# Options for add:
--prefix <path>          # Install to specific prefix

# Options for upgrade:
--latest                 # Upgrade to latest version (ignore semver)

Usage Examples:

# Install global packages
yarn global add yarn
yarn global add @vue/cli
yarn global add create-react-app
yarn global add typescript

# Remove global packages
yarn global remove create-react-app
yarn global remove @vue/cli

# List global packages
yarn global list
yarn global list --depth=0

# Upgrade global packages
yarn global upgrade
yarn global upgrade typescript

# Upgrade to latest versions (ignoring semver)
yarn global upgrade --latest
yarn global upgrade typescript --latest

# Show global bin directory
yarn global bin

# Add global bin to PATH
export PATH="$(yarn global bin):$PATH"

Global Package Location:

  • Linux/macOS: ~/.config/yarn/global
  • Windows: %LOCALAPPDATA%\Yarn\config\global
  • Binaries: $(yarn global bin) directory

Link Management

Create and manage symlinks for local development.

yarn link [package]                        # Link package from current directory
yarn unlink [package]                     # Unlink package

Usage Examples:

# In package directory - register for linking
cd /path/to/my-package
yarn link

# In consumer project - link to registered package
cd /path/to/my-project
yarn link my-package

# Unlink package
yarn unlink my-package

# In package directory - unregister from linking
cd /path/to/my-package
yarn unlink

Link Workflow:

  1. Register package: Run yarn link in package directory
  2. Link consumer: Run yarn link <package-name> in consumer project
  3. Development: Changes in package are immediately available in consumer
  4. Unlink: Run yarn unlink <package-name> to restore normal dependency

Link Registry Location:

  • Linux/macOS: ~/.config/yarn/link
  • Windows: %LOCALAPPDATA%\Yarn\config\link

Configuration Files

.yarnrc Configuration

Project-level configuration file (.yarnrc):

# Registry configuration
registry "https://npm.company.com"
"@company:registry" "https://npm.company.com"

# Cache settings
cache-folder "/tmp/yarn-cache"
offline-mirror "./offline-cache"

# Network settings
network-timeout 300000
network-concurrency 8

# Installation settings
ignore-scripts true
ignore-engines false
flat false

# Authentication
"//npm.company.com/:_authToken" "${NPM_TOKEN}"

Global Configuration

Global configuration location:

  • Linux/macOS: ~/.yarnrc
  • Windows: %USERPROFILE%\.yarnrc
# Global defaults
registry "https://registry.npmjs.org"
cache-folder "/Users/username/.yarn-cache"
disable-self-update-check true
ignore-engines true

Environment Variables

Yarn respects environment variables for configuration:

# Cache directory
YARN_CACHE_FOLDER=/path/to/cache

# Registry settings
YARN_REGISTRY=https://registry.npmjs.org

# Network settings
YARN_NETWORK_TIMEOUT=300000
YARN_NETWORK_CONCURRENCY=8

# Disable features
YARN_DISABLE_SELF_UPDATE_CHECK=true
YARN_ENABLE_OFFLINE_MODE=true

# Authentication
NPM_CONFIG_REGISTRY=https://npm.company.com
NPM_CONFIG__AUTH_TOKEN=${TOKEN}

# HTTP proxy
HTTP_PROXY=http://proxy.company.com:8080
HTTPS_PROXY=https://proxy.company.com:8080

Registry Configuration

Multiple Registries

# Default registry
yarn config set registry https://registry.npmjs.org

# Scoped registries
yarn config set @company:registry https://npm.company.com
yarn config set @internal:registry https://internal-npm.company.com

# Authentication for each registry
yarn config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
yarn config set //npm.company.com/:_authToken ${COMPANY_TOKEN}

Registry Authentication

# Token-based authentication
yarn config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}

# Basic authentication (base64 encoded username:password)
yarn config set //npm.company.com/:_auth ${BASE64_AUTH}

# Username/password authentication
yarn config set //npm.company.com/:username ${USERNAME}
yarn config set //npm.company.com/:_password ${BASE64_PASSWORD}
yarn config set //npm.company.com/:email ${EMAIL}

SSL Configuration

# Disable SSL verification (not recommended for production)
yarn config set strict-ssl false

# Custom CA certificate
yarn config set ca-file /path/to/ca-cert.pem

# Custom certificate files
yarn config set cert-file /path/to/client-cert.pem
yarn config set key-file /path/to/client-key.pem

Advanced Configuration

Workspace Configuration

# Enable workspace features
yarn config set workspaces-experimental true

# Workspace-specific settings
yarn config set workspace-experimental true
yarn config set workspace-tools true

Cache Configuration

# Cache settings
yarn config set cache-folder ~/.yarn-cache
yarn config set offline-mirror ./offline-packages
yarn config set disable-self-update-check true

# Cache cleanup
yarn config set cache-clean-interval 86400000  # 24 hours in ms

Network Optimization

# Network performance
yarn config set network-timeout 600000    # 10 minutes
yarn config set network-concurrency 16    # Concurrent requests
yarn config set child-concurrency 8       # Child processes

# Retry settings
yarn config set network-retry-count 3
yarn config set network-retry-delay 1000

Development Settings

# Development optimizations
yarn config set save-prefix "~"           # Use tilde for version ranges
yarn config set ignore-scripts false      # Allow lifecycle scripts
yarn config set ignore-engines false      # Check engine compatibility
yarn config set ignore-platform false     # Check platform compatibility

# Workspace development
yarn config set link-duplicates true      # Link duplicate packages
yarn config set link-folder ~/.config/yarn/link  # Link registry location

Configuration Hierarchy

Yarn uses configuration in this priority order (highest to lowest):

  1. Command line flags: --registry https://example.com
  2. Environment variables: YARN_REGISTRY=https://example.com
  3. Project .yarnrc: ./.yarnrc in project directory
  4. Parent .yarnrc: ../.yarnrc (and up the directory tree)
  5. Global .yarnrc: ~/.yarnrc (user home directory)
  6. System .yarnrc: /etc/yarnrc (system-wide, Linux/macOS only)
  7. Built-in defaults: Yarn's default configuration

Configuration Debugging

# Show effective configuration
yarn config list

# Show configuration sources
yarn config list --verbose

# Check specific configuration value
yarn config get registry

# Test configuration
yarn install --verbose  # Shows which registry is being used

Configuration Best Practices

Project .yarnrc:

# Project-specific settings only
registry "https://npm.company.com"
"@company:registry" "https://npm.company.com"
network-timeout 300000

Global .yarnrc:

# User preferences and defaults
cache-folder "/Users/username/.yarn-cache"
disable-self-update-check true
network-concurrency 8
save-prefix "^"

Environment Variables (CI/CD):

# In CI/CD environment
export YARN_CACHE_FOLDER=/tmp/yarn-cache
export YARN_REGISTRY=https://npm.company.com
export YARN_DISABLE_SELF_UPDATE_CHECK=true
export NPM_CONFIG__AUTH_TOKEN=${NPM_TOKEN}

Install with Tessl CLI

npx tessl i tessl/npm-yarn

docs

cache-management.md

configuration.md

index.md

information-commands.md

package-management.md

project-management.md

registry-operations.md

utility-commands.md

workspace-management.md

tile.json