Run Backend and Frontend with a Single Command
I’ve been thinking about how I run my projects.
I’ve always done it like this: I run the backend and the frontend in two tabs in the system terminal (Bash or zsh). I know there are Git shortcuts in VS Code, but I like to use Git commands in the VS Code terminal, so I don’t run the projects there.
With that in mind, it’s a bit annoying to go into the folders in two tabs and run both, so I looked for solutions. I found npm-run-all and concurrently, but I don’t like installing extra tools just to do simple things, so I thought about using an alias to run both with a single command.
In the terminal, run the following command:
nano ~/.bashrc
This will open the bashrc file. At its last line, add the following (replacing the path and the command according to your project):
alias run-project="(cd project/backend && npm run dev) & (cd project/frontend && npm run dev)"
Press Ctrl+O to save the file and Ctrl+X to exit. Then, run the command below in the terminal to reload the terminal configuration file without having to close and reopen the terminal:
source ~/.bashrc
Now just run the command below in the terminal, and it will start both your backend and frontend at the same time.
run-project
Thank you for reading this article! Share your thoughts about it — knowledge is always welcome!




Excelente, Axel! Que artigo super prático e valioso sobre "Run Backend and Frontend with a Single Command"! É fascinante ver como você aborda um problema comum no desenvolvimento full stack: a necessidade de rodar o backend e o frontend em duas abas separadas no terminal, o que pode ser um pouco chato e cansativo.
Você demonstrou que a solução foi usar um alias para rodar ambos com um único comando, o que é um insight valioso para a comunidade. Sua análise de que a automação e a simplificação de tarefas repetitivas são o que realmente impulsionam a produtividade de um desenvolvedor, é um insight valioso para a comunidade.
Qual você diria que é o maior desafio para um desenvolvedor ao criar um alias ou um script para automatizar o deploy de uma aplicação, em termos de segurança (executar comandos maliciosos, por exemplo) e de compatibilidade do script (já que comandos do Windows são diferentes dos do Linux), em vez de uma abordagem mais segura e portátil?