I'm developing a discord bot for discord at the moment, and to run the bot, I have a few different files. I've run into some problems along the way that all ended up having the same fix, or at least the only fix that I could e up with. That fix would be, instead of running them in my main file (index.js), I could just run 3 separate batch files using nodemon (). I currently have 3 batch files to do so. Those batch files look like this:
nodemon index.js
pause
This would be for the main file.
nodemon logs.js
pause
This would be for the file that logs messages.
nodemon wele and goodbye.js
pause
And this would be for the wele and goodbye logs.
The only issue is, is that it clutters up my desktop with 3 different prompts, making it confusing as to what does what. I was wondering if it'd be possible with nodemon (or any other npm like this) for me to run all 3 of those batch files in one single mand prompt.
And of course I'm open to other npms, but if I'd have to use another one, please include a way for it to automatically restart the server when I save the file in it as well (if possible). Since that's the main reason I like nodemon. I'd also like to be able to use a mand prompt/batch file rather than the Visual Studio Code terminal.
If you're wondering what I mean when I say, "...automatically restart the server when I save the file," . (.jpg if it doesn't show, don't know how to format this stuff) Whenever I save my code in Visual Studio it will restart and load the new code.
I'm still a little new to coding and stuff like that, so if my terminology is off I do apologize. If I did use a term incorrectly and you are confused/have a question about it, leave a ment and I will do my best too explain what I mean.
Thank you for taking time to read this.
I'm developing a discord bot for discord at the moment, and to run the bot, I have a few different files. I've run into some problems along the way that all ended up having the same fix, or at least the only fix that I could e up with. That fix would be, instead of running them in my main file (index.js), I could just run 3 separate batch files using nodemon (https://www.npmjs./package/nodemon). I currently have 3 batch files to do so. Those batch files look like this:
nodemon index.js
pause
This would be for the main file.
nodemon logs.js
pause
This would be for the file that logs messages.
nodemon wele and goodbye.js
pause
And this would be for the wele and goodbye logs.
The only issue is, is that it clutters up my desktop with 3 different prompts, making it confusing as to what does what. I was wondering if it'd be possible with nodemon (or any other npm like this) for me to run all 3 of those batch files in one single mand prompt.
And of course I'm open to other npms, but if I'd have to use another one, please include a way for it to automatically restart the server when I save the file in it as well (if possible). Since that's the main reason I like nodemon. I'd also like to be able to use a mand prompt/batch file rather than the Visual Studio Code terminal.
If you're wondering what I mean when I say, "...automatically restart the server when I save the file," . (https://i.sstatic/fMk4y.jpg if it doesn't show, don't know how to format this stuff) Whenever I save my code in Visual Studio it will restart and load the new code.
I'm still a little new to coding and stuff like that, so if my terminology is off I do apologize. If I did use a term incorrectly and you are confused/have a question about it, leave a ment and I will do my best too explain what I mean.
Thank you for taking time to read this.
Share Improve this question asked Nov 17, 2019 at 7:21 Peppa PapaPeppa Papa 955 silver badges14 bronze badges2 Answers
Reset to default 4You 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
Here's an example setup
Wele :-)
I think you mean bash file (.sh
) instead of batch file. So, in the terminal, you can &&
mands to chain them together.
For example, you could chain them together like this:
nodemon ./appOne/index.js && nodemon ./appTwo/index.js && nodemon wele and goodbye.js
and they will all execute at one time. Additionally, you could make a bash file somewhere on your puter 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
)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745197400a4616162.html
评论列表(0条)