How To Run Both Your Backend And Your Client Server With One Command.

joevega

Joseph Bouhanef

Posted on April 4, 2022

How To Run Both Your Backend And Your Client Server With One Command.

Have you ever felt like you’re running your servers way too often and thought to yourself, "Maybe my life would be simpler if I just had to do this once instead of twice every time?" This can be time consuming when adding new features to the backend or installing new packages in the middle of a production.

A Life Saver Package

Concurrently is a Node Package Manager that will help you in avoiding the need to execute several commands to launch your servers. You could run all commands on separate terminals, but I'm sure you, like most people, wish there was an easier solution.

As the name implies, this package allows you to execute your client and backend server simultaneously with a single command.

INSTALLATION

In the package.json of your root directory, add these scripts below:

"start": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"",
"server": "nodemon index.js",
"client": "cd client && npm start"

All that remains is to put your new tool to the test!

In your Terminal, go to the root directory of your project and run:

npm start

You're all set! Your server and your front-end should be running at the same time.

💖 💪 🙅 🚩
joevega
Joseph Bouhanef

Posted on April 4, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related