Installation Guide
This guide provides detailed instructions for installing and configuring Sistema de Productos on your system. Follow these steps for a complete setup from prerequisites through production deployment.Prerequisites
Before installing Sistema de Productos, ensure your system meets these requirements:Node.js
Required Version: Node.js 18.x or higher (tested with v24.13.1)Check Current Version
Verify your Node.js installation:If the version is below 18.x or Node.js is not installed, proceed to the next step.
Install Node.js
Download and install Node.js from nodejs.org
PostgreSQL
Required Version: PostgreSQL 12.x or higherGit (Optional)
Required for: Cloning the repositoryInstallation Steps
1. Download the Project
2. Install Dependencies
Install all required npm packages:Frontend Dependencies
[email protected]- Progressive JavaScript framework[email protected]- Official router for Vue.js[email protected]- State management library[email protected]- HTTP client for API requests[email protected]- Utility-first CSS framework
Backend Dependencies
[email protected]- Web application framework[email protected]- PostgreSQL client for Node.js[email protected]- JWT authentication[email protected]- Password hashing[email protected]- Cross-origin resource sharing[email protected]- Cookie parsing middleware[email protected]- Email sending functionality
Development Dependencies
[email protected]- Frontend build tool[email protected]- Auto-restart for backend development[email protected]- Run multiple commands simultaneously[email protected]- Environment variable management
Troubleshooting npm install
Troubleshooting npm install
If you encounter issues during installation:Error: EACCES permission deniedError: node-gyp build failedNetwork or timeout errors
3. Database Setup
Run Schema Script
Execute the database schema file to create tables, views, and sample data:This creates:
- 3 Tables: Categorias, Productos, Usuarios
- 3 Views: ProductosView, CategoriasView, UsuariosView
- Extension: pgcrypto for password encryption
- Sample Data: 4 categories and 19 products
- Admin User: Default administrator account
Database Schema Details
Database Schema Details
The database includes the following structure:Tables:Views provide formatted date/time fields for easier frontend consumption.
4. Environment Configuration
Create and configure the environment variables file:Generate Secure JWT Secret
Create a cryptographically secure JWT secret:Copy the output and replace
your_jwt_secret_key_here in your .env file.5. Start the Application
Run the development servers:- Frontend (Vite): http://localhost:5173
- Backend (Express): http://localhost:3000
Configuration Details
Backend Server Configuration
The backend is configured inserver/index.js and server/app.js:
Database Connection Configuration
Database connection is managed inserver/config/database.js:
Frontend Configuration
Vite configuration invite.config.js:
Production Deployment
Build for Production
Verification and Testing
Test API Endpoints
Test Frontend Access
- Open browser to
http://localhost:5173 - You should see the login page
- Login with default credentials:
- Username:
admin01 - Password:
Admin01*
- Username:
Verify Database Connection
Check backend console output:Troubleshooting
Database Connection Errors
Database Connection Errors
Error:
Connection refused or could not connect to serverSolutions:-
Verify PostgreSQL is running:
-
Check PostgreSQL is listening on the correct port:
-
Verify
.envdatabase credentials are correct -
Check PostgreSQL allows local connections:
-
Test manual connection:
Port Already in Use
Port Already in Use
Error:
EADDRINUSE: address already in useSolutions:-
Find process using the port:
-
Kill the process:
-
Or change the port in
.env:
Module Import Errors
Module Import Errors
Error:
Cannot find module or ERR_MODULE_NOT_FOUNDSolutions:-
Verify
package.jsonhas"type": "module" -
Ensure all imports use
.jsextensions: -
Reinstall dependencies:
-
Check Node.js version (must be 18+):
JWT Token Errors
JWT Token Errors
Error:
jwt malformed or invalid tokenSolutions:-
Verify
JWT_SECRETis set in.env - Clear browser cookies and try logging in again
- Check cookies are enabled in browser
-
Verify CORS settings allow credentials:
Frontend Build Errors
Frontend Build Errors
Error: Build failures or Vite errorsSolutions:
-
Clear Vite cache:
- Verify all Vue files have correct syntax
- Check for circular dependencies
-
Rebuild:
bcrypt Installation Issues
bcrypt Installation Issues
Error:
bcrypt fails to install or buildSolutions:-
Install build tools:
-
Rebuild bcrypt:
- Or use bcryptjs as alternative (update package.json)
Default Admin Account
The database setup creates a default administrator account:- Username:
admin01 - Password:
Admin01* - Email:
[email protected] - Role:
Administrador
Next Steps
Your installation is complete! Here’s what to do next:- Explore the Application: Log in and familiarize yourself with the interface
- Review the Code: Examine the project structure and implementation
- Customize: Modify categories, add products, create users
- API Testing: Use Postman or curl to test API endpoints
- Development: Start building new features or modifications
For a quick overview of features and usage, refer back to the Introduction page.
