How To Run Multiple Js Servers
Solution 1:
You can use concurrently or parallel in order to make it cross platform
example with concurrently:
package.json
{
"scripts": {
"serve": "nodemon index.js",
"logs": "nodemon logs.js",
"start": "concurrently \"npm:serve\"\"npm:logs\""
},
"devDependencies": {
"concurrently": "^5.0.0",
}
}
Edit: you may want to take a look at the VSCode Compound tasks
Solution 2:
Welcome :-)
I think you mean bash file (.sh
) instead of batch file. So, in the terminal, you can &&
commands to chain them together.
For example, you could chain them together like this:
nodemon ./appOne/index.js && nodemon ./appTwo/index.js && nodemon welcome and goodbye.js
and they will all execute at one time. Additionally, you could make a bash file somewhere on your computer that did exactly what I typed above :-)
Now if you wanted them to go to the background and you wanted to forget about them, you could put them in the background with one ampersand... like so:
nodemon index.js &
and it would disappear and you'd have your console back. It would also print out a process ID (PID) of what that node process is under, so you can find it and kill it later (via kill -9 processid
)
Post a Comment for "How To Run Multiple Js Servers"