10

I would like to debug my sails.js application but I don't know how to launch node-inspector for this occasion.

Normally it would go :

$ node --debug myapp.js

If I run my sails application normally :

$ sails lift --prod

and then launch node-inspector

$ node-inspector --debug-port 1337
Node Inspector v0.7.0-2
   info  - socket.io started
Visit http://127.0.0.1:8080/debug?port=1337 to start debugging.

I get this error in inspector GUI :

Error: read ECONNRESET. Check there is no other debugger client attached to port 1337.
Patryk
  • 22,602
  • 44
  • 128
  • 244
  • possible duplicate of [How to debug a basic node.js application (not http) on windows](http://stackoverflow.com/questions/11437958/how-to-debug-a-basic-node-js-application-not-http-on-windows) – Francisco Corrales Morales Mar 29 '15 at 22:03

2 Answers2

11

As of Sails 0.9.8 you can use sailsd to call sails in debug mode, e.g. sailsd lift.

-- Edit --

Looks like this didn't actually make it into 0.9.8, my bad. To make your own debugging command for now, save the following into /usr/local/bin as sailsd (or whatever you like):

#!/bin/sh
node --debug `which sails` $@

-- Edit 2 --

In Sails v0.10.x, you can do sails debug instead of sails lift to start Sails in debug mode!

sgress454
  • 24,870
  • 4
  • 74
  • 92
6

Correct me if im wrong but, you cant use debug port 1337 if sails lifts on port 1337.

try specifying a different port.

node --debug app.js
#this will lift sails on port 1337 and the default debug port i think its 5858
#start node-inspector, once it starts hit enter to put it into background
node-inspector &;
#visit http://127.0.0.1:8080/debug?port=5858

edit just confirmed this method works, instead of using sails lift you're using node to start app.js in debug mode. the node-inspector web runs on port 8080 and the debugger links on port 5858 by default.

NDBoost
  • 10,184
  • 6
  • 53
  • 73
  • it'd be great if there was a flag available in sails to enable debug mode.. Im going to poke around a bit. – NDBoost Jan 26 '14 at 17:43