Local development lets you build and test the full registration flow — HTML form, Node.js HTTP server, and MySQL database — entirely on your own machine before deploying anywhere. This guide walks through every step from cloning the repository to opening the app in your browser.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/brandonvergara1220-del/Mini-Proyecto-Backend-NodeJS/llms.txt
Use this file to discover all available pages before exploring further.
System Requirements
Make sure the following are installed before you begin:| Requirement | Minimum Version |
|---|---|
| Node.js | v14+ |
| npm | v6+ |
| MySQL or MariaDB | MySQL 5.7+ / MariaDB 10.3+ |
Clone the Repository
Download the project source to your local machine and navigate into the project directory.
Install Dependencies
Install the required Node.js packages. The only production dependency is After this step you will see a
mysql2.node_modules folder and a package-lock.json file in the project root.Set Up MySQL
Start your MySQL server and create the database that You can run these statements in the MySQL CLI, MySQL Workbench, or any compatible client.
conexion.js expects. The connection is configured for localhost, user root, and an empty password — adjust these values in conexion.js if your setup differs.Implement server.js
The
server.js file in the repository is intentionally left empty — implementing it is the student’s task for this activity (GA7-220501096-AA2-EV02). The server must:- Serve
index.htmlonGET / - Accept form submissions on
POST /recuperardatos - Insert the submitted
nombreandapellidovalues into theusuariostable using the exportedconexionfromconexion.js
The code above is a reference implementation provided for learning purposes. The actual
server.js file in the repository is empty — you are expected to write your own solution as part of the SENA ADSO activity.Start the Server
Use the npm script defined in This runs
package.json to launch the server:node server.js. A successful start prints:Open the App in Your Browser
Navigate to http://localhost:3000 in any modern browser. You should see the registration form defined in
index.html. Fill in the Nombre and Apellido fields and click Enviar to submit a record to the usuarios table.Troubleshooting
MySQL connection refused
MySQL connection refused
The error
Error: connect ECONNREFUSED 127.0.0.1:3306 means the Node.js process cannot reach MySQL. Common causes and fixes:- MySQL is not running. Start the service with
sudo service mysql start(Linux) or via the MySQL tray icon / System Preferences (macOS/Windows). - Wrong credentials. Open
conexion.jsand verifyhost,user, andpasswordmatch your local MySQL configuration. - Database does not exist. Run
CREATE DATABASE IF NOT EXISTS ejemploformulario;in the MySQL CLI and restart the server.
Port already in use
Port already in use
The error Alternatively, change the port number in
Error: listen EADDRINUSE: address already in use :::3000 means another process is occupying port 3000.Find and stop the process:server.js (e.g., 3001) and restart.Module not found: mysql2
Module not found: mysql2
The error If the error persists, delete
Cannot find module 'mysql2' means the dependency was not installed. Run:node_modules and package-lock.json and try again: