Search code examples
node.jsvagrantmeanjsnode-inspector

How to setup node-inspector with vagrant?


I have an meanjs application running on a vagrant box. My vagrantfile is as follows

 config.vm.network "forwarded_port", guest: 27017, host: 27016 #mongodb
 config.vm.network "forwarded_port", guest: 1337, host: 1338 #node inspector

 config.vm.network "private_network", ip: "192.168.33.10"

node inspector configuration is as follows

'node-inspector': {
  custom: {
    options: {
      'web-port': 1337,
      'web-host': 'localhost',
      'debug-port': 5858,
      'save-live-edit': true,
      'no-preload': true,
      'stack-trace-limit': 50,
      'hidden': []
    }
  }
},

I am not able to get the node inspector working on my host machine whenever

http://192.168.33.10:1338/debug?port=5858

with vagrant I am able to get the node-inspector working on the local machine without vagrant


Solution

  • I figured the problems was the number of concurrent tasks configured for grunt-concurrent module. By default its equal to the number of cores in the pc. In my case it was two. So My node-inspecter module configuration in gruntfile.js

     concurrent: {
      default: ['nodemon', 'watch'],
      debug: ['node-inspector', 'nodemon', 'watch'],
      options: {
        logConcurrentOutput: true,
        limit: 5
      }
    

    There is also no debug in the hyperlink .It should be.

    http://192.168.33.10:1337/?port=5858
    

    Port forwarding was required for both the ports to get the node inspector

    config.vm.network "forwarded_port", guest: 1337, host: 1337   
    config.vm.network "forwarded_port", guest: 5858, host: 5858