Sign in

How to start up a Node js backend using Express

Using Node is a great tool for a React frontend. It is also easy to get started first you need to create a directory. Once you have a created a directory you can touch index.js and index.html files. In your terminal you can open your project. I am using VScode so I will use code . to open my project.

After this command is entered you can just click through several times and this will spin up your package.json. After this there are a few more commands you want to enter.

After you run this command you will see node_express inside your package.json and you will also notice node_modules folder. This is a good time to create a .gitignore file and add node_module file to that.

Next you will want to require your express and set it to a variable in your index.js file.

Next you will want to create a get to your home page server and set a string to Hello World.

After this you will want to set up a server that Node can watch on.

Once this is done you can type in the command node index.js and go to localhost:8081 and you should see Hello World!

Congratulations you just created your first node backend!

Thanks for reading and happy coding!