I have written two node.js projects and one of them is a simple crud and another one has two methods to audit the crud operation of previous project.The auditing project used to audit the crud operations of another project and auditing project use as a micro service for my crud operations based projects.Actually it is like a rest service calling from another rest service. Can you give me some guidance to complete above task please?
Asked
Active
Viewed 988 times
0
-
What's the specific problem? You have two node projects, just run them both. – Dave Newton Sep 04 '20 at 04:10
-
1pm2 is great for doing these sorts of things https://futurestud.io/tutorials/pm2-start-multiple-apps-with-a-single-process-file-json-js-yaml#:~:text=Configure%20Multiple%20Applications%20in%20a%20Single%20JSON%20File,-Within%20a%20previously&text=Within%20the%20JSON%20file%2C%20PM2,defined%20options%20with%20respective%20values. – alilland Sep 04 '20 at 05:51
-
Also highly recommend pm2 – Kubie Sep 04 '20 at 06:19
1 Answers
1
To run two node.js projects in parallel you have several options:
- Start your projects with
node appA.js && node appB.js
or, - Add the same in your script in your package.json:
{ start: "node appA.js && node appB.js", test: ... }
or, - Use npm-run-all (
npm install --save-dev npm-run-all
). And then add a script to run in parrallel like this:
...
scripts: {
start: "run-p runA runB",
runA: "node appA.js",
runB: "node appB.js",
test: ...
},
...
Note that run-p
will run A and B in parallel. Alternatively you could use run-s
to run in series, one after another, if you needed that. Bear in mind that the first two options will work only on Unix. While the last one is cross-platform.
Related SO questions and resources:

adelriosantiago
- 7,762
- 7
- 38
- 71