Reputation:
My client code and server code are not in the same folder. I know that if I want to run backend and frontend together I can install and use concurrently library, however, every example to this i can find is always where client and server code are in same project folder so I can run something like that:
"start": "node index.js",
"client": "npm run start --prefix client",
"dev": "concurrently \"npm run start\" \"npm run client\""
my project structure is like this:
myGreatApp
/src
/node_modules
....
my server side code is in another folder:
myGreatApp-server
/models
/controller
/node_modules
...
How can I do that? Thanks!!
Upvotes: 0
Views: 1905
Reputation: 108
As long as these two folders share the same parent folder, i.e:
root
/myGreatApp
/myGreatApp-server
you have to only navigate yourself out of your current repo and inside of the other one.
Your server-side package.json should look like this:
"client-install": "npm install --prefix client",
"start": "node index.js",
"server": "nodemon index.js",
"client": "cd ../ && npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\""
And your client-side package.json should look like this:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000",
Then you can simply run npm run dev
and they'll both run concurrently.
Upvotes: 1