wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install --lts
node -v
npm -v
npm install -g react-devtools
not sure if you can use Vite/Bootstrap/MySQL2 that's already in the repo, let's see.
- Clone this repo
- cd appropriately and then:
- Terminal 1:
node server.js - Terminal 2:
npm run dev
- Terminal 1:
-
Create a new Vite project with React template:
npm create vite@latest hms-website --template react
-
Change directory to the project folder:
cd hms-website -
Install project dependencies:
npm install
-
Install Bootstrap:
npm install bootstrap
-
Add Bootstrap CSS to your project. Open
hms-website/src/main.jsxand add the following line:import 'bootstrap/dist/css/bootstrap.min.css';
-
Navigate back to the root directory:
cd .. -
Create a new server directory and change to it:
mkdir server cd server -
Initialize a new Node.js project:
npm init -y
-
Install required packages:
npm install express mysql2
-
Create a server file and add the following code to
server/server.js:const express = require('express'); const app = express(); const PORT = process.env.PORT || 5000; // Middleware app.use(express.json()); // Example route app.get('/', (req, res) => { res.send('Hello from the server!'); }); app.listen(PORT, () => { console.log(`Server is running on http://localhost:${PORT}`); });
Add the following code for MySQL connection in your server file:
const mysql = require('mysql2');
const db = mysql.createConnection({
host: 'localhost',
user: 'your_username',
password: 'your_password',
database: 'your_database'
});
db.connect((err) => {
if (err) throw err;
console.log('Connected to MySQL Database!');
});- Terminal 1: Start your server.
- Terminal 2: Run the front-end:
npm run dev