After installing nodeJs from: https://nodejs.org/en/download/ and visual studio code from: https://code.visualstudio.com/download and GitBash from: https://git-scm.com/downloads we can start developing backend of project but before start we need a little knowledge about nodeJS.
* What exactly is Node.js?
* What is Git Bash?
Git bash is a msys shell included in "Git for Windows", and is a slimmed-down version of Cygwin (an old version at that), whose only purpose is to provide enough of a POSIX layer to run a bash. Reminder: msysGit is the development environment to compile Git for Windows.
1- open git bash and make a folder in your selected address for back end example you can make a new folder in Git Bash with #mkdir command and open the folder in VScode environment with #code.. command
2- Add a new .js file to the folder and name it server.js. This file is server of project add below codes to the server.js file:
I tried to explain very brief about per line of codes in server.js in the comment at the picture but for more information you can watch the video on this link: https://expressjs.com/
3- right click on server.js and select open in terminal option and at the terminal with npm init command and answer questions of new file (can answer just by enter) make a new file (package.json)
4- Now with npm install express command install express module on your project to can run it. At the end with node server or node server.js command run your project
5- In this step should make a route to solve Cannot Get / error on our project. So we should make a new folder (routes) and add a new .js file (html-routes.js) to it. After writing html-routes.js and running project you should see Hello from simple-react project on the browser on localhost:3000 address
6- Now we have to connect to the MySQL database. SO we should add some more code for making a connection between database and server on server.js file:
7- Now with npm instal mysql command at the terminal we should add MySQL module to the project. After run we will see below error on the terminal and we have to do another step to fix it. This is an issue in MySQL version 8
put username and password of your database
At the end: