0
0
AstroHow-ToBeginner ยท 3 min read

How to Install Astro: Quick Setup Guide

To install Astro, first ensure you have Node.js installed. Then run npm create astro@latest in your terminal to create a new Astro project with the latest version.
๐Ÿ“

Syntax

The basic command to install Astro is npm create astro@latest. This command downloads the latest Astro project starter and guides you through setup.

  • npm: Node.js package manager used to run commands.
  • create: Tells npm to run a project scaffolding tool.
  • astro@latest: Specifies the Astro starter package and ensures you get the newest version.
bash
npm create astro@latest
๐Ÿ’ป

Example

This example shows how to create a new Astro project named my-astro-site. It will prompt you to choose a template and install dependencies.

bash
npm create astro@latest my-astro-site
cd my-astro-site
npm run dev
Output
โœ” Project created at ./my-astro-site โœ” Dependencies installed Local: http://localhost:3000/
โš ๏ธ

Common Pitfalls

Common mistakes include:

  • Not having Node.js installed or using an outdated version (Astro requires Node.js 16.8 or higher).
  • Running npm create astro without @latest may install an older version.
  • Not navigating into the project folder before starting the dev server.

Always check your Node.js version with node -v before starting.

bash
Wrong:
npm create astro

Right:
npm create astro@latest
๐Ÿ“Š

Quick Reference

Summary tips for installing Astro:

  • Use npm create astro@latest to start a new project.
  • Ensure Node.js version is 16.8 or higher.
  • Run npm install inside your project folder before starting the dev server.
  • Start development with npm run dev.
โœ…

Key Takeaways

Use the command npm create astro@latest to install the latest Astro starter.
Make sure Node.js version is 16.8 or newer before installing Astro.
Navigate into your project folder and run npm install to install dependencies.
Start your Astro development server with npm run dev.
Avoid omitting @latest to prevent installing outdated versions.