How to Fix astro: command not found
Seeing sh: astro: command not found? Your project's tools aren't installed, or you're in the wrong folder. Here's the two-minute fix, tested on Astro 7.4.
Tested on Astro 7.4

astro: command not found means your terminal can’t find Astro. Most of the time, you haven’t run npm install yet. Go to your project folder, run npm install, then run npm run dev. That fixes it nine times out of ten.
Why it happens
Astro is not a program on your computer, like a web browser. It lives inside each project, in a folder called node_modules. npm puts it there when you run npm install.
So there are three ways to get this error:
- You didn’t run
npm install. This is common after you download a project, copy a folder, or clone one from GitHub. Thenode_modulesfolder isn’t there yet. - You’re in the wrong folder. Your terminal is open in a folder with no project in it.
- You typed
astro devon its own. Your terminal can’t see insidenode_modules. It needsnpm run devornpx astro devto find Astro.
We made a fresh Astro 7.4 project, deleted its node_modules folder, and ran npm run dev. This is what we got:
$ npm run dev
> x@0.0.1 dev
> astro dev
sh: astro: command not foundTyping astro dev on its own gave the same kind of error, even in a project that was installed. In bash it said bash: astro: command not found. On a Mac, the terminal may say zsh: command not found: astro. It’s the same problem.
How to fix it
- Check your folder. Run
ls(ordiron Windows). You should seepackage.jsonin the list. If you don’t, usecdto move into your project folder first. - Install the tools. Run
npm install. It takes a minute. When it’s done, you’ll see a newnode_modulesfolder. - Start Astro the right way. Run
npm run dev. If you want to type an Astro command yourself, putnpxin front, likenpx astro dev.
After npm install, we checked that Astro was there:
$ npx astro --version
astro v7.4.7Then npm run dev started the dev server with no errors.
Still stuck?
- Check that Node.js is installed. Run
node -v. If you getcommand not foundfornodetoo, install Node.js first. - If
npm installshows red errors, copy the first one and ask an AI to explain it. - Ask a real person in our community.
Where to go next
- How to fix the most common Astro errors covers the other errors beginners hit.
- Why is my Astro site on port 4322? if your site opens at a strange address.
Frequently asked questions
Do I need to install Astro on my whole computer?
No. Astro lives inside each project, in a folder called node_modules. You install it with npm install in that project. Nothing goes on the rest of your computer.
Why does npm run dev work but astro dev doesn't?
Your terminal can't see the tools inside your project on its own. npm run dev knows where to look. So does npx astro dev. Typing astro dev alone does not.
Do I have to run npm install every time?
No. Run it once after you make or download a project. Run it again only if you add a new package or delete the node_modules folder.
Stuck on a step?
Check the common errors guide, look up a word in the glossary, or ask the friendly people in the official Astro and EmDash Discords. How to ask so people can help.