Reputation: 10425
In order to debug with node-inspector
I need to start my app with the node --debug
command. Up to this point I have only used sails lift
to start my Sails.js app, so I am unsure of how to start my app using the normal node
command.
Upvotes: 11
Views: 7371
Reputation: 382830
node inspect
You can also use the command line debugger with:
node inspect app.js
This stops at the beginning, so do a continue:
c
And now, when your code with a statement:
debugger
gets executed, you fall into the Node CLI debugger as usual.
Tested on Sail v1.1, Node v10.15.1, Ubuntu 18.10.
nodemon --inspect
and nodemon inspect
You can use those to inspect when using nodemon
, which automatically reloads the app on file save: Auto reloading a Sails.js app on code changes?
Those options are analogous to node inspect
and node --inspect
: node inspect
works with debugger
statements, and node --inspect
works with the Chrome debugger.
Especially useful with the "Open dedicated DevTools for Node" feature: Can I get node --inspect to open Chrome automatically
nodemon inspect
is a bit annoying as it requires a continue
everytime you make any app changes and nodemon
restarts the server. TODO find a way around it.
Upvotes: 1
Reputation: 51
sails inspect
since Sails v1.0
As of sails v1.0, sails debug
is deprecated for newer Node.js, and you should instead use sails inspect
.
This is documented at: https://sailsjs.com/documentation/reference/command-line-interface/sails-inspect and is presumably done to match the newer node --inspect
interface.
Upvotes: 2
Reputation: 4165
As of Sails v0.10.x, you can do sails debug
instead of sails lift
.
Upvotes: 7
Reputation: 10425
So you can actually launch a sails
project with node app.js --debug
if you have sails
installed in your project, rather than only system-wide. Go to your project's root directory and run npm install
. Sails should already be in your package.json
and thus should install to your project directory.
Upvotes: 9
Reputation: 5376
Have you tried using node-webkit to run your node.js apps? This is what we use at work to debug our node.js server applications. It is quite useful runtime based on chromium which you can use to inspect your code using familiar breakpoints, stack traces, variable inspection and such without having to rely on node-inspector (which I find hard to use to be honest).
What you do is instead of using console command 'node you-app.js' you set the node-webkit to launch your app, run the webkit then open its console (which is the same as console in Chrome browser) and from there you can open your source files and start debugging like any other client side JavaScript code.
Upvotes: 1