Edit Page

sails debug

This command should only be used with older versions of Node. For Node v6 and above, use sails inspect.
#

Attach the node debugger and lift the Sails app (similar to running node --debug app.js). You can then use node-inspector to debug your app as it runs.

sails debug

Usage

#

Takes the same options as sails lift, listed here.

Example

#
$ sails debug

info: Running node-inspector on this app...
info: If you don't know what to do next, type `help`
info: Or check out the docs:
info: http://nodejs.org/api/debugger.html

info: ( to exit, type <CTRL>+<C> )

debugger listening on port 5858

To use the standard (command-line) Node debugger with Sails, you can always just run node debug app.js.

Using Node Inspector

#

To debug your Sails app using Node Inspector, first install it over npm:

$ npm install -g node-inspector

Then, launch it with the node-inspector command:

$ node-inspector

Now, you can lift your Sails app in debug mode:

$ sails debug

Once the application is launched, visit http://127.0.0.1:8080?port=5858 in Opera or Chrome (Sorry, other browsers!). Now you can request your app as usual on port 1337 and debug your code from the browser.

How it works Node.js includes a TCP-based debugger. When you start your application using sails debug, Node.js lifts your app and opens a socket on port 5858. This socket allows external tools to interact with and control the debugger. Node Inspector, accessible via the port 8080, is this kind of tool.

If you don't see your files in the browser at http://127.0.0.1:8080?port=5858 or if it's very slow to load, try running Node Inspector with the --no-preload argument. See the Node Inspector repo for more details.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

Reference