Process to make node server:

  1. run code npm init – y
  2. run code npm i express mysql nodemon
  3. After install no-2 then create page index.js
  4. Put code in index.js
    import express from “express”
    import express from “express”;
    import mysql from “mysql”;
    const app = express()
    const db = mysql.createConnection({
    host: “localhost”,
    user: “root”,
    password: “”,
    database: “nodedb”
    app.get(“/”, (req, res) => {
        res.json(“Hello this is backend”)
    app.get(“/test”, (req, res) => {
        const q = “SELECT * FROM `test`”
        db.query(q, (err, data) => {
            if (err) return res.json(err)
            return res.json(data)
    app.listen(8800, () => {
        console.log(“connect DB”)
  5. run code npm start if issue then modify package.json after this “main”: “index.js”,
    “type”: “module”,
    And add line in scripts
    “start”: “nodemon index.js”
  6. then again run npm start
  7. open run mysql then same db connection needed.

    This is a way to start first to make node server with mysql connecttion