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.
After installing run it using node-inspector command as shown below. As you can see in the above figure, it will display an URL for debugging purpose. So, point your browser to http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858 and start debugging. Sometimes, port 8080 might not be available on your computer.
Attach the Node debugger and lift the Sails app (similar to running node --inspect app. js ). You can then use a tool like Chrome DevTools to interactively debug your apps (see the Node Inspector docs for more information).
A big reason why sails. js is hailed by developers is because of how suitable it is for building real-time features, like for example, a live chat option. It is also very compatible with Angular and Backbone. In short, it is the perfect framework for customised enterprise applications which are heavy on data.
Node Inspector is a debugger interface for Node. js applications that uses the Blink Developer Tools (formerly WebKit Web Inspector). Since version 6.3, Node. js provides a built-in DevTools-based debugger which mostly deprecates Node Inspector, see e.g. this blog post to get started.
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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With