Installation
This guide covers everything you need to install and configure Villa Buena E-Commerce for development or production use.Prerequisites
Before installing Villa Buena, ensure you have the following installed:Node.js
Version 18.0.0 or higherDownload from nodejs.org
Package Manager
npm, yarn, or pnpmnpm comes with Node.js
Git
For cloning the repositoryDownload from git-scm.com
Code Editor
VS Code recommendedWith ESLint extension
Verify Prerequisites
Check that everything is installed correctly:Installation Methods
- NPM
- Yarn
- PNPM
Using NPM
Install Dependencies
package.json:12-22:Core Dependencies:[email protected]&[email protected]- UI library@auth0/[email protected]- Authentication@tanstack/[email protected]- Data fetching[email protected]- Routing[email protected]- State management[email protected]- HTTP client[email protected]- UI framework[email protected]- Icons
Configuration
Environment Variables
Villa Buena uses Vite’s environment variable system. All variables must be prefixed withVITE_ to be exposed to client code.
Create a .env file in the project root:
.env
The API URL is consumed by the axios instance in
src/services/api.js:4 using import.meta.env.VITE_API_URL.Auth0 Configuration
The application includes pre-configured Auth0 credentials for demo purposes (seesrc/main.jsx:15-20). For production use, configure your own Auth0 application:
Create Auth0 Account
Sign up at auth0.com for a free account.
Create Application
- Go to Applications > Create Application
- Choose “Single Page Web Applications”
- Select React as the technology
Configure Settings
In your Auth0 application settings:
- Allowed Callback URLs:
http://localhost:5173, https://yourdomain.com - Allowed Logout URLs:
http://localhost:5173, https://yourdomain.com - Allowed Web Origins:
http://localhost:5173, https://yourdomain.com
Vite Configuration
The Vite configuration is minimal by default (vite.config.js):
vite.config.js
vite.config.js
Project Structure
After installation, your project will have this structure:Development Dependencies
The following dev dependencies are included (package.json:23-33):
- @vitejs/[email protected] - Vite React plugin with Fast Refresh
- [email protected] - Build tool and dev server
- [email protected] - Code linting
- [email protected] - React Hooks linting rules
- [email protected] - Fast Refresh linting
- @types/react & @types/react-dom - TypeScript definitions
- [email protected] - Global variable definitions for linting
Running the Application
After installation, use these commands frompackage.json:6-10:
Application Entry Point
The application bootstraps insrc/main.jsx:
src/main.jsx
Provider Hierarchy
- QueryProvider - Wraps app with TanStack Query client for data fetching
- Auth0Provider - Provides authentication context throughout the app
- RouterProvider - Handles client-side routing
Routing Configuration
Routes are defined insrc/app/router.jsx using React Router’s createBrowserRouter:
src/app/router.jsx
Layout component which provides:
- Navbar with authentication controls
- Toast notification system
- Cart drawer
- Dark mode theming
State Management Setup
Cart Store Example
The cart uses Zustand with persistence middleware (src/store/useCartStore.js):
src/store/useCartStore.js
The persist middleware automatically syncs cart state to localStorage, providing persistence across page refreshes.
Verification
Verify your installation by checking:Troubleshooting
Installation fails with EACCES errors
Installation fails with EACCES errors
Permission errors usually mean npm needs elevated privileges. Try:Or fix npm permissions: docs.npmjs.com/resolving-eacces-permissions-errors
Module not found after installation
Module not found after installation
Clear node_modules and reinstall:
Vite dev server won't start
Vite dev server won't start
Check if the port is already in use:Kill the process or change the port in
vite.config.js.Environment variables not loading
Environment variables not loading
Ensure your
.env file:- Is in the project root (not in src/)
- Uses
VITE_prefix for all variables - Has been created before running
npm run dev
.env.ESLint errors on startup
ESLint errors on startup
The project uses ESLint 9 with new flat config format. If you see errors:Review errors and fix or update
eslint.config.js as needed.Next Steps
Quick Start
Follow the quick start guide to explore core features
Architecture
Understand the application structure and patterns
API Services
Learn about the API service layer
State Management
Deep dive into Zustand stores
