How to create a Node.js contact form
As youâre reading this article, Iâm assuming you know how to install Node.js and create a new project, so allow me to keep it brief and get straight into setting up the project.
However, to freshen up your knowledge, you can check out this article on installing Node.js.
Setting up the project
First things first, letâs install some dependencies for our backend by opening the terminal and entering the following commands:
mkdir contact-form-test && cd contact-form-test
â By running this command, we create a folder for our project, ensuring our project file will be within it instead of the current directory.npm init -y
â This will create a package.json file that manages project dependencies and configurations.npm i express nodemailer
â We need to install Express.js library and Nodemailer module as we will need them for setting up our server and sending emails with SMTP, respectively.npm i -D nodemon
â This is a dev dependency that automates the process of restarting our server whenever we change our code, allowing us to see the changes we made without having us manually restart the server.
Once you install all the dependencies, your package.json file should look something like this: