Skip to content

/errors/yarn/command-not-found

yarn: error Command "dev" not found.

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
Yarn
exit code
1
versions
Yarn 1.22, Yarn 4.x
os
any

error Command "dev" not found. is Yarn 1 (Classic) saying that yarn dev or yarn run dev matched neither a script in package.json nor an executable in node_modules/.bin. Run yarn run with no arguments to see what exists, then add the missing script or use the right name. Yarn 2 and later report the same problem as Usage Error: Couldn't find a script named "dev".

Reproduce it (Yarn 1)

bash
cat > package.json <<'EOF'
{ "name": "app", "version": "1.0.0", "license": "MIT", "scripts": { "build": "echo build" } }
EOF
npx --yes yarn@1 dev

Output · exit 1

yarn run v1.22.22
error Command "dev" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The same mistake in Yarn 4

bash
cat > package.json <<'EOF'
{ "name": "app", "version": "1.0.0", "license": "MIT", "scripts": { "build": "echo build" } }
EOF
touch yarn.lock
npx --yes @yarnpkg/cli-dist@4 install > /dev/null 2>&1
npx --yes @yarnpkg/cli-dist@4 run dev

Output · exit 1

Usage Error: Couldn't find a script named "dev".

$ yarn run [--inspect] [--inspect-brk] [-T,--top-level] [-B,--binaries-only] [--require #0] <scriptName> ...

An empty yarn.lock marks the folder as a Yarn project root, and Yarn 4 needs an install before it runs scripts.

Fix

Add the script, or call the name that exists:

bash
cat > package.json <<'EOF'
{ "name": "app", "version": "1.0.0", "license": "MIT",
  "scripts": { "build": "echo build", "dev": "echo dev server" } }
EOF
npx --yes yarn@1 --silent dev

Output

dev server

What yarn NAME looks up

OrderYarn 1Yarn 2+
1Script in package.json "scripts"Script in package.json "scripts"
2Binary in node_modules/.binBinary of a declared dependency
3error Command "NAME" not found.Usage Error: Couldn't find a script named "NAME".

A Yarn built-in command with the same name (yarn install, yarn add, yarn test in older versions) is not looked up as a script. Use yarn run NAME to force the script.

Sources