Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js debugging with node-inspector and forever.js

I am unable to debug node.js server when using forever.js. Is it not possible?

Exampel: forever start --debug server.js

1) Starts the server.js ok, but I am unable to debug with node-inspector.

2) forever.js as: forever start server.js Does not re-start the server - this is the core service of forever?

I am working on a mac.

Thanks Regards

like image 751
Chris G. Avatar asked Oct 10 '12 12:10

Chris G.


People also ask

Which of the following is Agui best debugging tool for Node JS?

38) Which of the following is a GUI-based debugging tool for Node. js? Answer: D is the correct option. Node Inspector is a GUI-based debugging tool for Node.

Which CLI option can you use to debug a node?

A minimal CLI debugger is available with node inspect myscript. js . Several commercial and open source tools can also connect to the Node.


2 Answers

Starts the server.js ok, but I am unable to debug with node-inspector.

Forever does not support debug mode out of the box. You can get around it by asking forever to start a custom command:

$ forever -c 'node --debug' server.js

Does not re-start the server - this is the core service of forever?

I assume you would like to restart the server after a change in source files. I am not very familiar with forever, but I would say you forgot to add -w option to the command line?

    -w, --watch      Watch for file changes

To debug a process and have it automatically restarted, run

$ forever -w -c 'node --debug' server.js

See also this node-inspector issue: #196.

like image 71
Miroslav Bajtoš Avatar answered Oct 29 '22 01:10

Miroslav Bajtoš


Complete instructions on Windows with Chrome

In first terminal run

forever -w -c "node --debug" server.js

In second terminal run

node-inspector

Navigate to localhost:8080

like image 32
ykay says Reinstate Monica Avatar answered Oct 29 '22 01:10

ykay says Reinstate Monica