Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

336
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!