yarn-dlx

Run packages without installing

TLDR

Run a package without installing
$ yarn dlx [create-react-app] [my-app]
Run a specific package version
$ yarn dlx [gatsby]@[4.0.0] new [my-site]
Run a command from a different package
$ yarn dlx -p [typescript] tsc --version
Run with quiet output
$ yarn dlx -q [cowsay] "Hello"
Run a command with multiple package dependencies
$ yarn dlx -p [typescript] -p [ts-node] ts-node --transpile-only -e "console.log('hello')"
Scaffold a Next.js app
$ yarn dlx create-next-app [my-app]

SYNOPSIS

yarn dlx [-p package] [-q] command [args]

DESCRIPTION

yarn dlx runs a package in a temporary environment without permanently installing it. This is the Yarn equivalent of npx, useful for one-off commands like project scaffolding tools.The command downloads the specified package to a temporary location, executes the package's binary scripts within the current working directory, and cleans up afterward. It's commonly used with generators like create-react-app, create-next-app, and gatsby that create new project structures.By default, yarn dlx uses the command name to determine which package to install. Use -p to specify a different package when the command name differs from the package name.

PARAMETERS

-p package, --package package

Designate which package to install before executing the command. Can be specified multiple times to install multiple packages.
-q, --quiet
Suppress detailed installation logs and report only essential error messages.

INSTALL

sudo pacman -S yarn
sudo apk add yarn
sudo zypper install yarn
brew install yarn
nix profile install nixpkgs#yarn

CAVEATS

yarn dlx is available in Yarn 2+ (Berry) only; Yarn 1.x does not include this command. Using dlx for packages needed repeatedly is not recommended since Yarn doesn't track dlx-installed packages, making builds non-deterministic. For repeated use, install packages normally with yarn add.

HISTORY

yarn dlx was introduced in Yarn 2 (Berry) released in 2020 as part of the modernized Yarn architecture. It provides functionality similar to npx but integrated with Yarn's package resolution and caching system.

SEE ALSO

yarn(1), npx(1), npm(1)