Meteor debug on server side on windows with node-inspector - windows

I am running meteor on Windows, possibly a minority here. I searched and found solutions for Linux and possibly Mac but no one has provide solutions for Windows. Maybe someone can help?
First I modified the meteor.bat file under C:\Program Files (x86)\Meteor to included --debug as mentioned in other posts:
#echo off&&"%METEOR_PATH%\bin\node.exe" --debug "%METEOR_PATH%\app\meteor\meteor.js" %*
I started my node-inspector and received an instruction to visit 0.0.0.0:8080/debug?port=5858 to start debugging
I then started my meteor application, but when I go to http://127.0.0.1:8080/debug?port=5858 I saw two squares: one for Scripts, and one for console. Nothing came up when selecting Scripts.
Does Windows have the same issue as Linux, spawning two processes but only one with the debug flag?

Version 0.5.3 added the NODE_OPTIONS environment variable that passes those parameters directly to node.
So fire-up your favorite js debugger like node-inspector
Assuming you already have it installed, call
node-inspector
Then
set NODE_OPTIONS = --debug
meteor
Do this inside your project folder, you can also use the --debug-brk to break immediately on start
In Chrome open localhost:8080 in a new tab
Have fun

Related

Why does run fail after I compile a GoLang project to Web Assembly?

I created a Go(lang) project in Visual Studio Code. I created a main.go file that I will compile to WebAssembly, and another main.go that I will run as a server (to serve my Web Assembly glue file).
For reference, I'm following the tutorial here: https://golangbot.com/webassembly-using-go/
In a Visual Studio Code terminal, I do the following:
[cd to my wasm source folder with the first main.go]
${env:GOOS} = "js"
${env:GOARCH} = "wasm"
go build -o ../../assets/json.wasm
[cd to my server folder with the other main.go]
go run main.go
[I get the following error]
exec: "C:\Users\...\AppData\Local\Temp\go-build3258126417\b001\exe\main": file does not exist
I was able to run this server prior to the build. What's going on?
This should have just run. But now I'm not able to run the server. I get that strange "file does not exist" error.
I spent a lot of time trying to figure this out and finally got it! Here's the deal:
Either or both of the GOOS and GOARCH environment variables that are required by the build go command (for webassembly) seem to conflict with the go run command. I don't know why. I discovered this in a backwards kind of way.
(TLDR: use different terminals to build and run and don't set these environment variables globally -- set them prior to every build. Use the Terminal>Split Terminal to maintain the build settings between tests! ).
Using the Visual Studio Code Powershell terminal, I set these 2 variables (or so I thought) and then ran the build. Then I ran the server to try to see the fruits of my labor and got a strange error in the Chrome console (something about expecting one magic word but receiving another). It turns out this error is fairly generic and after some googling, determined it probably meant something happened with my build. After trying a few more times unsuccessfully to build, I decided to set the environment variables in windows (as SYSTEM variables) so that I didn't have to keep setting them when I did my build.
I built again (still no build errors), but then when I went to run the server, I got the
exec: "C:\Users...\AppData\Local\Temp\go-build3258126417\b001\exe\main": file does not exist
error. At this point, I couldn't run any of my Go servers in any project. Since the only "global" thing I'd done was set those 2 environment variables, I decided to remove them. I could now run my Go servers. But I still couldn't execute my builds in the browser. What's going on??
I figured that since setting the global environment variables had an effect (albeit, a negative effect) whereas I hadn't experienced that issue when manually setting them directly in the terminal prior to each build, then maybe there was something wrong with the way I was setting the variables (I don't use Powershell very often).
After more googling and some experimentation, I discovered the "correct" way to set these variables in the terminal (noted in my original question). So manually setting them (the right way) prior to the build fixed the build issue (it wasn't building correctly since those variables weren't being set properly).
Now I knew the variable were getting set properly because now I was getting that error when I set them manually prior to the build. So now what?
I killed the terminal after build, and then started a new terminal, and the run was successful.
So bottom line: the GOOS and GOARCH environment variables should not be set when running a server, so don't start a server in the same terminal that you used to build the web assembly code!

Connect Debugger to NPM shell script that runs other repos, in VSCODE

I am using VSCODE on mac and trying to run a debugger to stop at breakpoints, when running an NPM script.
The NPM script is a shell script (.sh) and it starts a "watcher" on 4 different repos, that form my local server for the project.
The issue is that when I run the debugger on the relevant NPM script (using vscode's 'debug script' option), it seems like VSCODE has a debugger attached, but it never stops at my breakpoints.
The server itself seems to work fine.
I read a lot of answers regarding debugging NPM scripts, but they always refer to a .js file.
Am I not connecting the debugger in the correct way?
Is it possible to debug a shell script that runs this way?
My guess is that the debugger is only connected to the shell script which works fine, but "doesn't know" about the breakpoints in the actual repos that are launched with the script.
Would appreciate any help.
Thank you.

How to add Cargo to PATH required for pywinpty when deploying to Heroku?

I am getting the following error on Windows:
Cargo, the Rust package manager, is not installed or is not on PATH.
remote: This package requires Rust and Cargo to compile extensions.
I've installed Rust and cargo is in the path, but the problem persists. Does anybody know why this is happening?
Error message is the same as in this post.
Heroku's stack runs on Ubuntu. Cargo is required by pywinpty but that's a library required for communicating with Windows processes. You may need it for your local environment but you don't need it for Heroku. You should try removing pywinpty from your requirements.txt when you deploy to Heroku.
If you want a temporary solution
Open a command line prompt (cmd) and execute
path
that will show you the actual, current path. Inspect it to see whether the necessary directories are really absent. If they are, execute
path=%path%;directory you want to add;other directory you want to add
The path will be available in the command prompt for as long as it's open. If they are present, reboot the computer, the addition to the path may have been delayed after installation.
The permanent solution
For Win10 but I guess instructions are not very different for other flavors.
Open System properties, find Environment Variables. In the dialog that pops up you will see System Variables, among which you will see Path. Select it, click edit and add the directories you need via the New button. Close all popup boxes and reboot (always a good idea when Windows is stubborn ;-) )

Launch VSCode from source through WSL

I would like to build/launch the VSCode source code in the native Bash for Windows client. I have followed the steps outlined in the VSCode wiki on how to contribute, and everything is working as expected (All commands have been run on the WSL terminal following the Linux instructions)
After running yarn run watch, I try to launch VSCode by running DISPLAY=:0 ./scripts/code.sh from the source code directory, but nothing happens. I get two duplicate warnings:
[21496:1128/120229.392130:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected
but I'm not sure if this is causing the problem. I have an X Server client running, and have used to to successfully launch native Windows applications through WSL (terminator, emacs, etc.)
Is what I'm trying to do possible? If so, how can I make it work?
Amazing that you asked this! I was attempting to do the exact same thing at (it seems) the exact same time. Here's my process.
Install XMing
Install the xfree apps
Set DISPLAY=:0
Run xeyes ==> Awesome googly eyes!
Attempt to build vscode from source. The build docs seem to be incomplete b/c I had to install a ton of libraries beyond those listed e.g.
yarn
gulp
gulp-cli
pkg-config
libx11-dev
libxkbfile-dev
libsecret-1-dev
libgtk2.0-dev
libxss-dev
gnome-dev
libgconf2-dev
libnss3-dev
libasound2-dev
Eventually get the yarn tasks to finish such that I could run code.sh
./scripts/code.sh
[20474:1128/153959.035267:ERROR:bus.cc(427)] Failed to connect to the bus: F
ailed to connect to socket /var/run/dbus/system_bus_socket: No such file or
directory
[20474:1128/153959.081986:WARNING:audio_manager.cc(295)] Multiple instances
of AudioManager detected
[20474:1128/153959.082101:WARNING:audio_manager.cc(254)] Multiple instances
of AudioManager detected
Looking at ps I see that the process was running.
Conjectures
It seems that building from source from WSL is not yet supported. Or maybe you can build the artifact, but you can't connect to the Windows display to show it. Based on the quality of the xeyes session, it looks like a very, very, very primitive experience e.g. still using WinXP-style minimize / maximize / close icons.
I was literally writing an Issue on their github page when I thought I'd do one last search and found this post. Much of vscode treats WSL as a second-class environment on Windows. Recent work seems to suggest that things are going to get better as driving to integration between Windows' two internal environments continues to improve (e.g. https://github.com/Microsoft/vscode/issues/39144)
Update 2017-11-30
Based on some pursuit via Github, it seems that this issue has been reported to the WSL team: https://github.com/Microsoft/WSL/issues/2293. It appears to be under active consideration by the WSL team. I've added some commentary about my use case there.

Can't run any commands in zsh: "Command not found"

I am simply trying to set up a dev environment to code on my Windows 10 PC for use alongside my Mac when I need it.
I have installed Bash, Z shell and Node.js.
All I want to do, bare minimum, is simply:
Be able to run npm commands, etc. (npm install X)
Open files with appropriate programs from the terminal. (on Mac, I can run open index.html or atom .)
My problem: Literally no commands work. I can't run node -v, I can't do start index.html, I can't even open the current directory I'm in with explorer.
For every command, I receive an error: zsh: Command not found (:node/start/explorer/etc.)
I am guessing it has something to do with my PATH variables? I'm not sure; I'm relatively new...
Please help - I've spent four hours searching Google, Stack Overflow, page after page, but somehow can't find a solution.
Thanks.
Sounds like you have an 'eco-system challenge'... :)
Perhaps whatever tool you used to install the tools you mention:
did not do a complete install OR
requires a 'reboot' to enable all the goodies?
I suggest using a small footprint Linux OS in a VM for this type of tinkering; there are many challenges in using *nix tools on Windows - better to learn/experiment in a more Bash-friendly environment, and then, when comfy, bring the tool sets to another OS.
If you still want to give things a whirl:
locate your Bash binary
Right-click and select 'run as admin'
then use your favorite online Bash tutorial or book to explore...
:)
Dale

Resources