Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/plugin-dlx/sources/commands/dlx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,27 @@ export default class DlxCommand extends BaseCommand {

By default Yarn will download the package named \`command\`, but this can be changed through the use of the \`-p,--package\` flag which will instruct Yarn to still run the same command but from a different package.

Version ranges can be appended to the package name using the \`@\` suffix (e.g. \`pkg@1.0.0\` or \`pkg@^2\`). When no range is specified, Yarn will use the \`latest\` dist-tag.

When a package ships multiple binaries, use \`-p,--package\` to specify the package (with an optional version) and pass the desired binary name as the command. If the binary name matches one of the package's binaries it will be invoked directly; otherwise Yarn will report a \`Binary not found\` error.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without using -p, I think the default is to run the bin with the same name as the package name? If so please clarify that -p is only needed when running a bin that does not match the package name or when needing multiple packages.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.


Using \`yarn dlx\` as a replacement of \`yarn add\` isn't recommended, as it makes your project non-deterministic (Yarn doesn't keep track of the packages installed through \`dlx\` - neither their name, nor their version).
`,
examples: [[
`Use create-vite to scaffold a new Vite project`,
`yarn dlx create-vite`,
], [
`Run a specific version of a package`,
`yarn dlx create-vite@5.0.0`,
], [
`Install multiple packages for a single command`,
`yarn dlx -p typescript -p ts-node ts-node --transpile-only -e "console.log('hello!')"`,
], [
`Run the \`tsc\` binary from a specific version of typescript`,
`yarn dlx -p typescript@5.0.2 tsc --version`,
], [
`Run an alternate binary (\`tsserver\`) from the same package`,
`yarn dlx -p typescript@5.0.2 tsserver`,
]],
});

Expand Down