I am building an application in node.js with VS Code...
the application have multiple .js files:
buyBOT.js
getDeposit.js
getTransaction.js
when I run the debug I would expect to run within the selected .js file, but instead it always stars to run in the first .js file (buyBOT.js)...
For example:
Scenario 1) I am in the buyBOT.js I "press F5" to start debug and everything is fine... (buyBOT.js debugging)
Scenario 2) I am in the getDeposit.js I "press F5" to start debug and instead of running the code in getDeposit.js, the debugger bring up buyBOT.js and start the debug there.
What am I doing wrong? is there a parameter to change/set?
Related
I have android project using java which uses a nodejs server hosted on heruko. What I want is to run a local server before androidTest(instrument test), I have tried writing batch(bash*) file and running my server as an external tool.
That doesn't work async and stops the test. Any help with this would be highly appreciated.
This is how serverScript.bat looks:
cd C:\intern.apply
start node server test
Update v1:
I found a way to run my bash* file from gradle. But there is 1 problem, it always run, I want it to run only when someone runs androidTests (robitium/acceptance tests) from android studio. Right now I have this task in gradle.build (Project:AppName)
task mytask() {
ant.exec(
executable: 'serverScript.bat',
spawn: true
)
}
In your bash (not batch) file, have you tried running the server in background?
run_server & --> will be processed in background and the script continues
run_tests
stop_server
My problem is that it seems that on Windows 10 a desktop link (.lnk) that opens a console application in a minimized window makes all windows opened by this console application to be also minimized.
I would like to start Node.js in a minimized console window, but at the same time make Node.js opn open the browser in a maximized window ( this makes sense, since I'm not interested in the console output, rather I want the output in the browser window ).
opn("http://localhost:9000") // but hey, in maximized window!
Is there any way I can achieve this either by Node.js or by some Windows manipulation?
I made it. It is a Windows trick.
Based on this answer:
How do I minimize the command prompt from my bat file
if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit
... script logic here ...
exit
This a trick for a script to run itself in a minimized window. But somehow the property inherited from the .lnk remains maximized, so the browser window opened by the script running in its self minimized window opens the browser maximized.
There is a workaround, at least in my used case. But this just minimized the node console only. It will still appear in the taskbar.
I just created a shortcut with
Target: C:\WINDOWS\system32\cmd.exe /c start /min node < Your Application >
Start in: < Path to your application >
"Start in" is not required if you specify the full path to your application
Examples:
Target: C:\WINDOWS\system32\cmd.exe /c start /min node "C:\Users\jjyong\Documents\Programming\Node\PriceTracking\app.js"
Or
Target: C:\WINDOWS\system32\cmd.exe /c start /min node app.js
Start in: C:\Users\jjyong\Documents\Programming\Node\PriceTracking
Note:
I have only tested using NodeJS version 12.13.1 with PuppeteerJS running chromium with "headless: false"
I have accidentally delete source code of nodejs application, but this application is running, so how can I get source code back from running app?
I hope source code has been cached in some directory.
I was able to recover the full file by attaching the debugger (as TGrif suggested).
To actually recover the code:
Use setBreakpoint('app.js', 10), where 10 is a line of the code you know will be ran over again in the running process
Say pause, then next until it's paused on the script you want to recover.
Finally, say list(5000), where 5000 is an arbitrarily long number of lines to list.
You will now have your full script printed out, albeit with line numbers at the front, but you can use a site like this to remove them.
Hope this helps anyone who encounters this unique issue in the future, as this took me a couple hours to figure out.
There is maybe a way to retrieve some of your source code with the Nodejs debugger.
Assuming Linux OS, you need to get the process id of your application:
$ ps -e | grep node
Next you entering your app in debug mode with something like that:
$ kill -s USR1 PID
where PID is the pid of your node app.
Then your start the debug console:
$ node debug -p PID
If you have an app console, you'll see:
Starting debugger agent.
Debugger listening on port 5858
In your debug console you should see a debug prompt and you can get available commands with:
debug> help
I am able to show some of the running app source with the list command:
debug> list(NUMBER_OF_LINE)
where NUMBER_OF_LINE is the number of source code line you want to display.
I'm not sure this is a one shot try for you or not because my source code was not deleted.
Hope you can get some results.
IntelliJ IDEA 13 has really excellent support for Mocha tests through the Node.js plugin: https://www.jetbrains.com/idea/webhelp/running-mocha-unit-tests.html
The problem is, while I edit code on my local machine, I have a VM (vagrant) in which I run and test the code, so it's as production-like as possible.
I wrote a small bash script to run my tests remotely on this VM whenever I invoke "Run" from within IntelliJ, and the results pop up in the console well enough, however I'd love to use the excellent interface that appears whenever the Mocha test runner is invoked.
Any ideas?
Update: There's a much better way to do this now. See https://github.com/TechnologyAdvice/fake-mocha
Success!!
Here's how I did it. This is specific to connecting back to vagrant, but can be tweaked for any remote server to which you have key-based SSH privileges.
Somewhere on your remote machine, or even within your codebase, store the NodeJS plugin's mocha reporter (6 .js files at the time of this writing). These are found in NodeJS/js/mocha under your main IntelliJ config folder, which on OSX is ~/Library/Application Support/IntelliJIdea13. Know the absolute path to where you put them.
Edit your 'Run Configurations'
Add a new one using 'Mocha'
Set 'Node interpreter' to the full path to your ssh executable. On my machine, it's /usr/bin/ssh.
Set the 'Node options' to this behemoth, tweaking as necessary for your own configuration:
-i /Users/USERNAME/.vagrant.d/insecure_private_key vagrant#MACHINE_IP "cd /vagrant; node_modules/mocha/bin/_mocha --recursive --timeout 2000 --ui bdd --reporter /vagrant/tools/mocha_intellij/mochaIntellijReporter.js test" #
REMEMBER! The # at the end is IMPORTANT, as it will cancel out everything else the Mocha run config adds to this command. Also, remember to use an absolute path everywhere that I have one.
Set 'Working directory', 'Mocha package', and 'Test directory' to exactly what they should be if you were running mocha tests locally. These will not impact the test execution, but this interface WILL check to make sure these are valid paths.
Name it, save, and run!
Fully integrated, remote testing bliss.
1) In Webstorm, create a "Remote Debug" configuration, using port 5858.
2) Make sure that port is open on your server or VM.
3) On the remote server, execute Mocha with the --debug-brk option: mocha test --debug-brk
4) Back in Webstorm, start the remote-debug you created in Step 1, and and execution should pause on set breakpoints.
I want to run 2 post build events. I have separated the 2 commands by a full line break
Build Command
copy "$(TargetDir)$(ProjectName).xap" "C:\www\Proj\ClientBin\MyXap.xap"
iexplore "http://localhost/MyProj"
But when I add this and press build I get Exit code 9009.
It looks like its trying to execute a full single sommand but they are 2 seperate commands
The error from VS
Error 1 The command "copy "C:\Users\admin\Documents\Projects\MyXap\Bin\Debug\MyXap.xap" "C:\www\Proj\ClientBin\MyXap.xap"
iexplore "http://localhost/MyProj"" exited with code 9009. MyXap
Starting Internet Explorer appears to be the problem. At least two problems I saw, I needed to specify the full path and force the exit code to 0. No real idea why any of this is necessary. This test post-build event worked:
copy "$(TargetDir)$(ProjectName).exe" "c:\temp\test.exe"
"c:\program files (x86)\internet explorer\iexplore" "http://stackoverflow.com"
exit /b 0
Do note that it is very unusual to write a post-build event like this. It will only run if another file in the project requires recompilation. So you won't get the browser running when you press F5 twice in a row. This is very rarely desirable, favor using the Project + Properties, Debug tab, "Start external program" option instead.