Fast, reliable, and secure dependency management tool for JavaScript/Node.js projects
Additional utility commands for package integrity, security, maintenance, and project information.
Verify the integrity of installed packages and dependency tree.
yarn check [options]
# Options:
--integrity # Verify package integrity against checksums
--verify-tree # Verify dependency tree structure
--json # Output results in JSON formatUsage Examples:
# Basic integrity check
yarn check
# Check package integrity only
yarn check --integrity
# Verify dependency tree
yarn check --verify-tree
# Get JSON output for automation
yarn check --json
# Check specific aspects
yarn check --integrity --verify-treeCheck Process:
Run security audit to identify known vulnerabilities.
yarn audit [options]
# Options:
--level <severity> # Minimum severity level (low, moderate, high, critical)
--json # Output in JSON format
--groups <groups> # Audit specific dependency groupsUsage Examples:
# Run security audit
yarn audit
# Audit with minimum severity level
yarn audit --level moderate
yarn audit --level high
yarn audit --level critical
# Audit specific dependency groups
yarn audit --groups dependencies
yarn audit --groups devDependencies
# Get JSON output
yarn audit --json
# Audit production dependencies only
yarn audit --groups dependencies --level highAudit Output:
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Severity │ Package │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ High │ minimist │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ minimist │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Vulnerable │ <1.2.2 │
│ versions │ │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=1.2.2 │
└───────────────┴──────────────────────────────────────────────────────────────┘Create a compressed tarball of the package for distribution.
yarn pack [options]
# Options:
--filename <name> # Specify output filename
--json # Output metadata in JSON formatUsage Examples:
# Create tarball with default name
yarn pack
# Specify custom filename
yarn pack --filename my-package-v1.0.0.tgz
# Get JSON metadata
yarn pack --json
# Pack specific version
yarn version --new-version 1.2.3
yarn packPack Process:
prepack script (if defined)package.json#files.npmignore or .gitignorepostpack script (if defined)Import dependencies from other package managers' lockfiles.
yarn importUsage Examples:
# Import from package-lock.json
yarn import
# Workflow: npm to yarn migration
npm install # Generates package-lock.json
yarn import # Converts to yarn.lock
rm package-lock.json # Clean up npm lockfileImport Process:
package-lock.json (npm) or composer.lock (Composer)Generate a lockfile entry for a specific package.
yarn generate-lock-entry [options]
# Options:
--use-manifest <path> # Use specific package.json
--resolved <url> # Use specific resolved URLUsage Examples:
# Generate entry for package in current directory
yarn generate-lock-entry
# Generate entry with custom manifest
yarn generate-lock-entry --use-manifest /path/to/package.json
# Generate entry with specific resolved URL
yarn generate-lock-entry --resolved https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgzAutomatically remove unnecessary files from node_modules to save space.
yarn autoclean [options]
# Options:
--init # Initialize autoclean (creates .yarnclean)
--force # Clean without confirmationUsage Examples:
# Initialize autoclean
yarn autoclean --init
# Run autoclean
yarn autoclean
# Clean without confirmation
yarn autoclean --force
# Clean as part of install
yarn install && yarn autocleanAutoclean Process:
.yarnclean file for patternsExample .yarnclean:
# Remove documentation
*.md
LICENSE*
CHANGELOG*
# Remove test files
__tests__
test
tests
*.test.js
*.spec.js
# Remove source maps
*.map
# Remove TypeScript files
*.ts
!*.d.tsTemporarily unplug Plug'n'Play packages for debugging purposes.
yarn unplug <package> [options]
# Options:
--clear # Delete the selected packages
--clear-all # Delete all unplugged packagesUsage Examples:
# Unplug a package for debugging
yarn unplug react
# Unplug specific version
yarn unplug react@18.0.0
# Clear unplugged package
yarn unplug react --clear
# Clear all unplugged packages
yarn unplug --clear-allUnplug Process:
Manage yarn version policies and automatic updates.
yarn policies set-version <version>Usage Examples:
# Set specific yarn version for project
yarn policies set-version 1.22.22
# Set latest version
yarn policies set-version latest
# Set canary/beta version
yarn policies set-version canary
yarn policies set-version berryPolicy Management:
Display help information for yarn commands.
yarn help [command]Usage Examples:
# General help
yarn help
yarn --help
yarn -h
# Help for specific command
yarn help install
yarn help add
yarn help workspace
# List all commands
yarn help --commandsShow or update package version information.
yarn version [options]
# Options:
--new-version <version> # Set specific version
--major # Increment major version
--minor # Increment minor version
--patch # Increment patch version
--premajor # Increment to prerelease major
--preminor # Increment to prerelease minor
--prepatch # Increment to prerelease patch
--prerelease # Increment prerelease version
--preid <identifier> # Prerelease identifier (alpha, beta, rc)
--message <message> # Custom commit message
--no-git-tag-version # Don't create git tag
--no-commit-hooks # Skip git commit hooksUsage Examples:
# Show current version
yarn version
# Increment versions
yarn version --patch # 1.0.0 -> 1.0.1
yarn version --minor # 1.0.0 -> 1.1.0
yarn version --major # 1.0.0 -> 2.0.0
# Set specific version
yarn version --new-version 2.1.0
# Prerelease versions
yarn version --prerelease # 1.0.0 -> 1.0.1-0
yarn version --prerelease --preid beta # 1.0.0 -> 1.0.1-beta.0
yarn version --premajor --preid alpha # 1.0.0 -> 2.0.0-alpha.0
# Version without git tag
yarn version --patch --no-git-tag-version
# Version with custom commit message
yarn version --patch --message "Fix critical bug in authentication"Version Process:
preversion scriptversion script--no-git-tag-version)postversion scriptDisplay versions of yarn, Node.js, and system information.
yarn versionsUsage Examples:
# Show all versions
yarn versions
# Use in bug reports
yarn versions > versions.txtOutput Example:
{
"yarn": "1.22.22",
"node": "18.17.0",
"v8": "10.2.154.26-node.22",
"uv": "1.44.2",
"zlib": "1.2.13",
"brotli": "1.0.9",
"ares": "1.19.1",
"modules": "108",
"nghttp2": "1.57.0",
"napi": "8",
"llhttp": "8.1.1",
"openssl": "3.0.9+quic",
"cldr": "43.1",
"icu": "73.2",
"tz": "2023c",
"unicode": "15.0",
"os": "Linux 5.4.0-74-generic",
"cpu": "x64"
}# Pre-commit hook
#!/bin/sh
yarn check --integrity || {
echo "Integrity check failed!"
exit 1
}
# CI/CD pipeline check
yarn install --frozen-lockfile
yarn check --integrity --verify-tree# Security check script
#!/bin/bash
AUDIT_RESULT=$(yarn audit --json --level high)
if [ $? -ne 0 ]; then
echo "High severity vulnerabilities found!"
echo "$AUDIT_RESULT" | jq '.data.vulnerabilities'
exit 1
fi
# Auto-fix security issues (where possible)
yarn audit --level moderate || yarn upgrade# Build and pack workflow
yarn build
yarn test
yarn pack --filename "$(npm pkg get name | tr -d '\"')-$(npm pkg get version | tr -d '\"').tgz"
# Verify packed contents
tar -tzf *.tgz | head -20# Pre-install validation
yarn check --verify-tree 2>/dev/null || yarn install
# Post-install cleanup
yarn install && yarn autoclean && yarn check
# Version bump workflow
yarn test && yarn build && yarn version --patch && yarn publish{
"scripts": {
"preinstall": "yarn check --verify-tree || true",
"postinstall": "yarn autoclean && yarn audit --level high",
"prebuild": "yarn check --integrity",
"prepack": "yarn build && yarn test",
"version": "yarn build && git add -A dist",
"postversion": "git push && git push --tags",
"security-check": "yarn audit --level moderate --json | jq '.data.vulnerabilities | length'",
"clean-install": "rm -rf node_modules yarn.lock && yarn install"
}
}# Debug dependency resolution
yarn install --verbose
# Check for conflicting versions
yarn list --pattern "*" | grep -E "├─|└─" | sort | uniq -c | sort -nr
# Verify lockfile consistency
yarn install --frozen-lockfile --check-files
# Generate detailed dependency report
yarn list --json > dependency-report.json
# Check package sizes
yarn list --json | jq -r '.data.trees[] | "\(.name)@\(.version)"' | \
xargs -I {} sh -c 'echo -n "{}: "; npm view {} dist.unpackedSize 2>/dev/null || echo "unknown"'# Integration with npm-check-updates
npx npm-check-updates
yarn upgrade
# Integration with license-checker
npx license-checker --summary
yarn licenses list
# Integration with bundlephobia
yarn list --json | jq -r '.data.trees[].name' | \
xargs -I {} curl -s "https://bundlephobia.com/api/size?package={}" | jq '.'
# Integration with snyk
npx snyk test
yarn auditInstall with Tessl CLI
npx tessl i tessl/npm-yarn