Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

331
Visualizações
How to run the server simultaneously with the client in a nodeJS application using concurently when the files are in different folders

My project is split into 2 folders client and server in the client folder the usual react-create-app package.json in sever folder package.json with trace script

scripts: {
 start: node app.js
server: nodemon app.js
}

how can I run the script through npm start to run both the backend and the frontend at the same time

client
  -app.js
  -package.json
server
  -app.js
  -package.json

I found a solution that you can start from the server folder as follows

dev: "concurently" npm run server "" npm run client "

but how to start if package.json is in different folders

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

you need to cd into your root directory or where both client and server folders are and npm install, npm init, git init, touch gitignore and add /node_modules

In your package.json in your root directory add this:

"client": "cd client && npm start",
"backend": "cd server && nodemon server.js",
"dev": "concurrently \"npm run backend\" \"npm run client\"",

In your server directory, npm install and touch gitignore /nodemodules

In your package.json add this:

"scripts": {
"start": "node server.js",
"server": "nodemon server.js"

},

In your client folder, npm install and touch gitignore /node_modules

In your package.json add this:

  "scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"

}

Then you can always run your app and server by just cd into your main directory, and doing npm run dev.

Btw: Its hard to deploy servers to heroku when they are separated into a folder and they aren't in a root directory.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda