📖 Scenario: You want to start a new website project using Astro, a modern framework for building fast websites.First, you need to set up the project folder and install Astro using the command line.
🎯 Goal: Create a new Astro project by running the correct commands in the terminal and setting up the initial project files.
📋 What You'll Learn
Use the npm create astro@latest command to start a new Astro project
Name the project folder my-astro-site
Navigate into the project folder using cd my-astro-site
Install project dependencies with npm install
Start the development server with npm run dev
💡 Why This Matters
🌍 Real World
Developers use Astro to build fast, modern websites with ease. Setting up the project correctly is the first step to creating a live site.
💼 Career
Knowing how to install and start an Astro project is essential for frontend developers working with modern web frameworks.
Progress0 / 4 steps
1
Create a new Astro project folder
Run the command npm create astro@latest and when prompted, enter my-astro-site as the project name.
Astro
Hint
Use the npm create astro@latest command exactly and type my-astro-site as the folder name when asked.
2
Navigate into the project folder
Run the command cd my-astro-site to move into the new project folder.
Astro
Hint
Use the cd command followed by my-astro-site to enter the project folder.
3
Install project dependencies
Run the command npm install inside the my-astro-site folder to install all required packages.
Astro
Hint
Simply run npm install to get all packages needed for the Astro project.
4
Start the Astro development server
Run the command npm run dev to start the Astro development server and preview your site locally.
Astro
Hint
Use npm run dev to launch the local server and see your Astro site in the browser.
Practice
(1/5)
1. Which command do you use to start creating a new Astro project?
easy
A. astro init
B. npm install astro
C. npm run dev
D. npm create astro@latest
Solution
Step 1: Understand how to create a new Astro project
The official way to start a new Astro project is by running npm create astro@latest, which sets up the project files.
Step 2: Differentiate from other commands
npm install astro installs a package but doesn't create a project; npm run dev runs the project; astro init is not a valid command.
Final Answer:
npm create astro@latest -> Option D
Quick Check:
Create new Astro project = npm create astro@latest [OK]
Hint: Use 'npm create astro@latest' to start a new project [OK]
Common Mistakes:
Using 'npm install astro' to create a project
Trying 'astro init' which is invalid
Running 'npm run dev' before creating the project
2. Which command installs the dependencies inside your Astro project folder?
easy
A. npm run dev
B. npm create astro@latest
C. npm install
D. npm start
Solution
Step 1: Identify the command for installing dependencies
After creating the project, you run npm install inside the project folder to download all needed packages.
Step 2: Understand other commands' purposes
npm create astro@latest creates the project; npm run dev runs the development server; npm start is not standard for Astro.
Final Answer:
npm install -> Option C
Quick Check:
Install dependencies = npm install [OK]
Hint: Run 'npm install' to get all project dependencies [OK]
Common Mistakes:
Running 'npm create astro@latest' again to install
Using 'npm start' which is not standard here
Skipping dependency installation before running dev server
3. What happens when you run npm run dev inside your Astro project folder?
medium
A. It installs all project dependencies.
B. It starts a local development server to preview your site.
C. It builds the project for production.
D. It creates a new Astro project.
Solution
Step 1: Understand the purpose of 'npm run dev'
This command starts a local server that watches your files and shows your site live as you build it.
Step 2: Differentiate from other commands
npm install installs dependencies; creating a project is done by npm create astro@latest; building for production uses npm run build.
Final Answer:
It starts a local development server to preview your site. -> Option B
Quick Check:
npm run dev = start dev server [OK]
Hint: Use 'npm run dev' to preview your site live [OK]
Common Mistakes:
Confusing 'npm run dev' with installing dependencies
Thinking it creates a new project
Assuming it builds production files
4. You ran npm run dev but your site does not show up in the browser. What is the most likely cause?
medium
A. You did not install dependencies with npm install.
B. You forgot to create the project with npm create astro@latest.
C. You ran npm run dev outside the project folder.
D. You need to run npm start instead.
Solution
Step 1: Check dependency installation
If dependencies are missing because npm install was not run, the dev server may fail or not load properly.
Step 2: Consider other causes
Running npm run dev outside the project folder or forgetting to create the project can cause errors, but missing dependencies is the most common cause.
Final Answer:
You did not install dependencies with npm install. -> Option A
Quick Check:
Missing dependencies = run npm install first [OK]
Hint: Always run 'npm install' before 'npm run dev' [OK]
Common Mistakes:
Skipping 'npm install' after project creation
Running dev server outside project folder
Trying 'npm start' which is not standard
5. You want to create a new Astro project, install dependencies, and start the development server in the fewest commands possible. Which sequence is correct?
hard
A. npm create astro@latest -> npm install -> npm run dev
B. npm install -> npm create astro@latest -> npm run dev
C. npm create astro@latest -> npm run dev
D. npm run dev -> npm create astro@latest -> npm install
Solution
Step 1: Create the project first
You must first run npm create astro@latest to generate the project files.
Step 2: Install dependencies before running dev server
After creation, run npm install to get all packages, then npm run dev to start the server.
Step 3: Understand why other sequences fail
Running npm run dev before installing dependencies or creating the project causes errors; installing before creating is illogical.
Final Answer:
npm create astro@latest -> npm install -> npm run dev -> Option A
Quick Check:
Create -> Install -> Dev server = correct order [OK]
Hint: Remember: create project, install dependencies, then run dev [OK]
Common Mistakes:
Skipping 'npm install' after project creation
Running dev server before project exists
Installing before creating the project
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.