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.
Top comments (2)
Good job man ! Super useful
How often I forgot to start my backend server and wondered why no data is coming in? X-/
It's over now.
So thank you for that!