Free Astro tutorials for complete beginners.

Beginner's Guide to Astro

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

Cover image for How to Fix astro: command not found
In this guide
  1. Why it happens
  2. How to fix it
  3. Still stuck?
  4. Where to go next
  5. Frequently asked questions

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:

  1. You didn’t run npm install. This is common after you download a project, copy a folder, or clone one from GitHub. The node_modules folder isn’t there yet.
  2. You’re in the wrong folder. Your terminal is open in a folder with no project in it.
  3. You typed astro dev on its own. Your terminal can’t see inside node_modules. It needs npm run dev or npx astro dev to 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:

Terminal
$ npm run dev
> x@0.0.1 dev
> astro dev
sh: astro: command not found

Typing 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

  1. Check your folder. Run ls (or dir on Windows). You should see package.json in the list. If you don’t, use cd to move into your project folder first.
  2. Install the tools. Run npm install. It takes a minute. When it’s done, you’ll see a new node_modules folder.
  3. Start Astro the right way. Run npm run dev. If you want to type an Astro command yourself, put npx in front, like npx astro dev.

After npm install, we checked that Astro was there:

Terminal
$ npx astro --version
   astro  v7.4.7

Then npm run dev started the dev server with no errors.

Still stuck?

  • Check that Node.js is installed. Run node -v. If you get command not found for node too, install Node.js first.
  • If npm install shows red errors, copy the first one and ask an AI to explain it.
  • Ask a real person in our community.

Where to go next

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.

Keep reading

  1. How to Register a Domain Name and Connect It to Your Astro Site

    Buy a domain for about $11 a year, then point it at Cloudflare or Netlify. We did this for astronursery.com, and these are the exact steps.

    Tutorials, 8 minute read, November 8, 2026

  2. How to Add Google Analytics to an Astro Site (and a Simpler Option)

    Paste Google's tag into your Astro layout with one small change, is:inline, and it works on every page. Or use Cloudflare Web Analytics, which needs no cookie banner.

    Tutorials, 6 minute read, November 8, 2026

  3. How to Add a Contact Form to an Astro Site (No Server Needed)

    A static site can't receive form submissions on its own. A free form service can. Here's a working contact form in ten lines, with spam protection built in.

    Tutorials, 7 minute read, November 8, 2026

Try "blog", "deploy" or "EmDash".