yarn on Ubuntu prints a scenarios error instead of running JavaScript tooling
ERROR: There are no scenarios; must have at least oneShort answer
The yarn on your PATH is not the JavaScript package manager. On Debian and Ubuntu the cmdtest package ships a different tool called yarn, for scenario testing. Remove cmdtest, then install the real Yarn from its repository, or run it through Corepack or npm if cmdtest must stay.
Fix it fast
1Find out which cause you have
Ask the system which package owns the yarn command that runs. A path in /usr/bin that belongs to cmdtest confirms the cause.
which -a yarn dpkg -S "$(which yarn)"2Match what you see, then jump to its fix
What does the error look like?
ERROR: There are no scenarios; must have at least one
Cause 1 of 2
The cmdtest package put a different yarn on your PATH
1Check
The yarn from cmdtest is a scenario-testing tool for command-line programs. It wants a file with SCENARIO, GIVEN, WHEN and THEN blocks, so a bare yarn call finds none and stops.
dpkg -l cmdtest
man yarn | head -n 52Fix
The Yarn install guide tells you to remove cmdtest first when apt gives errors, then install Yarn from the Yarn package repository.
sudo apt remove cmdtest
sudo apt update && sudo apt install yarn3Verify
yarn now reports a version number.
hash -r
yarn --versionConfirmed by classic.yarnpkg.com
Cause 2 of 2
You need to keep cmdtest, so Yarn must come from somewhere else
1Check
apt lists the packages it will remove and waits for your answer. Read that list and answer n if anything you need is on it.
sudo apt remove cmdtest2Fix
Run Yarn through Corepack, which ships with Node.js before version 25 and puts yarn shims on your PATH, or install Classic Yarn with npm. Either way the first yarn found must be the new one, so check the order after installing.
corepack enable
# or, for Yarn 1 only
npm install --global yarn@13Verify
The first yarn in PATH is the one you installed.
which -a yarn
yarn --versionConfirmed by github.com
How do I stop it coming back?
- Pin the package manager in package.json with the packageManager field so everyone gets the same Yarn.
- In Dockerfiles and CI, install Yarn explicitly and print yarn --version early in the job.
- Do not install test tools from the distribution without checking which commands they add.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
Related fixes
Servers
Azure App Service on Linux restarts the container and the site never starts
The container restarts again and again and the site returns an application error
App Service sends a warmup request to the container and restarts it if no HTTP answer comes back in time.
5 causes, each with a fixServers
Cypress says the npm package is installed but the binary is missing
Cypress binary is missing after npm install in CI or in a Docker build
The npm package is only a launcher.
3 causes, each with a fixServers
A native Node.js module fails on AWS Lambda with invalid ELF header
Error: /var/task/node_modules/<package>/build/Release/<name>.node: invalid ELF header
Lambda loads native addons on Linux, so a .node file built on macOS or Windows is not a valid Linux ELF file there.
3 causes, each with a fixServers
nginx 502 Bad Gateway in front of a Node.js app
connect() failed (111: Connection refused) while connecting to upstream
A 502 means nginx reached for your Node.js app and got nothing usable back.
5 causes, each with a fixServers
nginx gives up waiting for the app and returns 504
upstream timed out (110: Connection timed out) while reading response header from upstream
nginx returns 504 when the app behind it takes the request but sends nothing back within proxy_read_timeout (60 seconds by default), or when the connection cannot be opened in time.
5 causes, each with a fixServers
Pages load unstyled because /_next/static files return 404 behind nginx
GET https://example.com/_next/static/chunks/main.js 404 (Not Found)
The browser asks for /_next/static/..
3 causes, each with a fix