Okay, so, I have 2 different files at the moment that I have made in Visual Studio Code. I am using node.js & discord.js , I'm attempting to make a discord bot. When I run the terminal and run "node ." (its how I usually activate my bot and run its commands, it only activates my index.js file and not the other file, which is called help.js. I can't seem to make both of these files be run at the same time, its either I activate "index.js" or "help.js" , and future thing is, I'm most likely going to make more different files and want them to run at the same time. Sorry if I wasn't clear enough, I didn't really know how to say it. I'm pretty much a beginner in programming and stuff :P
Assuming you didn't do a fancypants module structure (aka, assuming you didn't put exports in help.js), all you have to do is throw this line at the top of index.js:
require('./help.js');
(assuming help.js is in the same folder as index.js)
Then keep running node . as usual.
Related
I want to do one very simple thing. Every time I run a command on my VS Code terminal (I'm running small JS programs using node.js), I want to store the output to a text file. Something like this
node ./test_script.js > test_script.txt
Doing this just works. But there are many times I just forget to add the > test_script.txt part while quickly using the terminal. Is there any way to make that part happen by default?
It should automatically get appended to the terminal input if I run node ./test_script.js. I also want the output file to be named the same as the .js file but with .txt extension, so it is dynamically named.
If yes, what is that setting connected to? Is it a VS Code setting, a node.js setting, or a terminal setting? Will it work if I am running a python script as well?
Thanks!
during development I have a npm script I run that is just
jest --coverage=false --watch
However when I start typing in one of my file (and have not saved yet) jest directly starts executing again which usually leads to problems at test execution since I have not completed typing and syntax is off or sth. And then I need to wait for jest to finish, save my file and then see the real results. That kinds of destroys my workflow.
I cannot image that this is supposed to be like this but couldnt find really anything how to have a better workflow, since I want my tests not only to run at commit but at save.
How can I achieve that?
I'm fairly new with node.js. How can I recompile/rebuild to make changes in node_modules folder to take effect in my app? I just need to add a few temporary console.log lines to understand a module better.
JavaScript is an interpreted language so there is no need to recompile files in node_modules. For debugging you can simply navigate to the module you need to debug, add your console.log statements and you're ready to go.
It's a bit trickier if you use some C++ addons, but in most cases editing .js files is enough
I created a Python project in Pycharm which contains multiple Python files. As of just now, I need to create a run configuration for each Python file in my project, even though they're all the exact same - with the exception of the script.
This seems unnecessary and laborious and I would love to just use one run configuration for multiple Python files.
That said, I'm a novice Python programmer just getting started and so still unfamiliar with large parts of the language.
My Project Files:
My Run Configuration - Used for all Python files:
Some Research Carried Out
I've searched for a solution and explanation to this, but have been unable to find anything. Some of the places I've tried:
JetBrainsTV on youtube (https://www.youtube.com/watch?v=JLfd9LOdu_U)
JetBrains Website (https://www.jetbrains.com/help/pycharm/run-debug-configuration-python.html)
Stack Overflow
I hope there is sufficient detail here, if not I'd be happy to elaborate.
If those files are independent and you have nothing specific to them, then I see two simple ways of running them:
You don't have to manually create a run configuration for every file. You can just Right-Click on the file in the project tree and click "Run "
You can use the Terminal and run them files using the python interpreter as needed.
I was facing a similar situation when I started competitive programming. In my case I wanted to redirect my Test Cases from an input.txt file rather than manually typing the test cases for every run of my code. Using the above solution was not feasible, as I would need to manually change the Script Path and Redirect Input path in the Run Configuration window for every script I was running.
So what I wanted was, one run configuration, that would run all the scripts with Redirect Input path being set to input.txt.
To do that,
I created a main.py file with the following content:
import sys
if __name__ == '__main__':
fname = sys.argv[1]
exec(open(fname).read())
This main.py file is going to run my other python scripts.
Created this run configuration for the main.py file.
Now, every time I needed to run any code, with the code window open, ran this configuration, which actually executed main.py with current file name passed as its argument, which would then also take the inputs redirected from input.txt.
Hope this helps you or anyone trying to run multiple python scripts with a single run configuration in PyCharm.
I need to open PowerPoint presentations directly as Slideshow in my Electron App, which turned out to be a bit of a challenge.
To start direct in Presentation-Mode PowerPoint demands the Parameter "/s" given with the call to the .exe File.
I tried with the electron shell command and also with nodes child-process (which I would prefer), but I could not figure out how to pass the Parameter.
It would work this way:
const cp = require("child_process");
cp.exec('"c:\\Program Files (x86)\\microsoft office\\office14\\powerpnt.exe" /s "C:\\PathToPowerpoint\\file.pptx"')
The Problem is,
I cannot call powerpnt.exe this way, because I have no Idea which Version (and therefore which Path) of PowerPoint is installed on the Client Computer
It seems there is no way to attach the Parameter somewhere else. cp.exec('"C:\\PathToPowerpoint\\1.pptx /s"') (or anything like that) is not accepted by PowerPoint. It Starts, but in "normal" mode.
I have very few to no possibilities to change or control the files before opening (so no chance of changing every .pptx into a .ppsx)
Does anybody know if there is a way in Node to add PowerPoint to windows system path variables, or determine where "powerpnt.exe" resides on a specific Computer without scanning every Folder, or... any idea?