npm install -g node-inspector
– The straight forward option is to open VirtualBox and go to the machine configuration settings.
Virtual box machine settings
And then to Network -> advanced-> port forwarding:
Virtual box port forwarding
There you use VirtualBox’s Port Forwarding Rules window to forward ports. You don’t have to specify any IP addresses. Changes take effect immediately. — If you are using Vagrant, it’s easier. Write down this line in your vagrantfile (I use 3001 as an example)
config.vm.network :forwarded\_port, guest: 3001, host: 3001 # node-inspector
Chages will take effect next time you start your virtual machine.
Now you are all set to start using node-inspector. Go to your virtual machine console and run
node --debug your\_program.js
NOTE: make sure that the –debug flag comes before your/node/program.js or else you may see an EADDRINUSE error. and then, in another console, run
Originally published at leolanchas.com on March 15, 2014.