2012-06-14 14:11:12 8 Comments
Does anyone know a good method to debug server side code? I tried enable Node.js debug then use node-inspector but it does not show any of my code.
I end up using console.log but this is very inefficient.
Update: I found the following procedure works on my Linux machine:
When you run Meteor, it will spawn two processes
process1: /usr/lib/meteor/bin/node /usr/lib/meteor/app/meteor/meteor.js
process2: /usr/lib/meteor/bin/node /home/paul/codes/bbtest_code/bbtest02/.meteor/local/build/main.js --keepalive
You need to send kill -s USR1 on process2
Run node-inspector and you can see your server code
On my first try, I modify the last line on meteor startup script in /usr/lib/meteor/bin/meteor to
exec "$DEV_BUNDLE/bin/node" $NODE_DEBUG "$METEOR" "[email protected]"
and run NODE_DEBUG=--debug meteor
on command prompt. This only put --debug flag on process1 so I only see meteor files on node-inspector and could not find my code.
Can someone check this on Windows and Mac machine?
Related Questions
Sponsored Content
5 Answered Questions
[SOLVED] What is the difference between client-side and server-side programming?
- 2012-12-12 13:03:00
- deceze
- 38179 View
- 473 Score
- 5 Answer
- Tags: javascript php client-side server-side
36 Answered Questions
[SOLVED] How do I debug Node.js applications?
- 2009-12-15 22:50:07
- Fabian Jakobs
- 515753 View
- 1533 Score
- 36 Answer
- Tags: javascript node.js debugging google-chrome-devtools
29 Answered Questions
1 Answered Questions
1 Answered Questions
Why does meteor spawn lots of child processes
- 2013-05-27 15:22:18
- Iulian Moise
- 130 View
- 0 Score
- 1 Answer
- Tags: meteor
1 Answered Questions
[SOLVED] Server-side debugging not working [Meteor 1.2]
- 2015-12-15 23:00:23
- illya
- 188 View
- 0 Score
- 1 Answer
- Tags: javascript node.js debugging meteor webstorm
2 Answered Questions
[SOLVED] How to debug and log own code on the server side of Meteor?
- 2012-09-16 17:00:52
- Qichao Dong
- 6674 View
- 9 Score
- 2 Answer
- Tags: debugging node.js meteor serverside-javascript node-inspector
1 Answered Questions
Can I use node-inspector with meteor?
- 2012-04-17 09:20:07
- okubee
- 347 View
- 0 Score
- 1 Answer
- Tags: meteor node-inspector
12 comments
@user7378851 2017-01-05 11:14:31
for meteor 1.3.5.2, run
@Sabrina Leggett 2015-11-02 16:11:37
I like to set breakpoints via a GUI. This way I don't have to remember to remove any debugging code from my app.
This is how I managed to do it server side for my local meteor app:
start your app this way.
Open Chrome to the address it gives you. You MAY need to install https://github.com/node-inspector/node-inspector (it might come bundled with Meteor now? not sure)
You'll see some weird internal meteor code (not the app code you wrote). Press play to run the code. This code simply starts up your server to listen for connections.
Only after you press play you'll see a new directory in your debugger folder structure called "app". In there are your meteor project files. Set a breakpoint in there one the line you want.
Open the local address of your app. This will run your server side code and you you should be able to hit your breakpoint!
Note: you have to reopen the inspector and go through this process again each time your app restarts!
@Sander van den Akker 2013-02-22 10:20:59
In Meteor 0.5.4 this has become a lot easier:
First run the following commands from the terminal:
And then open
http://localhost:8080
in your browser to view the node-inspector console.Update
Since Meteor 1.0 you can just type
which is essentially a shortcut for the above commands, and then launch node inspector in your browser as mentioned.
Update
In Meteor 1.0.2 a console or shell has been added. It may come in handy to output variables and run commands on the server:
@Andrew Barber 2013-02-22 10:26:08
Thanks for posting your answer! Please be sure to read the FAQ on Self-Promotion carefully. Also note that it is required that you post a disclaimer every time you link to your own site/product.
@Sander van den Akker 2013-03-01 13:25:22
Thanks, I didn't know!
@fuzzybabybunny 2014-06-30 13:26:09
How do I disable this debugger? Every time I run
meteor
this debugger runs and locks up my meteor app from running anything client-side.@juanpastas 2014-07-01 21:30:55
console outputs always [object Object], for example :
console.log('asd') [object Object]
@juanpastas 2014-07-01 21:31:32
is it possible to print values? how?
@Tony Brix 2015-07-25 05:42:25
Is there any official documentation on
meteor debug
. I can't find my code to set a break point.@ferndopolis 2015-02-18 00:56:57
On Meteor 1.0.3.1 (update to Sergey.Simonchik answer)
Start your server with
meteor run --debug-port=<port-number>
Point browser to
http://localhost:6222/debug?port=<port-number>
Where
<port-number>
is a port you specify.In your code add a
debugger;
where you want to set your break point.Depending on where
debugger;
is invoked, it will either break on your client or server browser window with inspector opened.@Christian Fritz 2015-01-29 05:19:26
As of Meteor 1.0.2 probably the best way for server-side debugging is directly via the new built-in shell: with running server run
meteor shell
. More info here: https://www.meteor.com/blog/2014/12/19/meteor-102-meteor-shell@Tomas Romero 2014-11-18 17:44:46
If you prefer to use nodeJS' official debugger you can call
NODE_OPTIONS='--debug' meteor
and then (on a different shell)node debug localhost:5858
.@juanpastas 2014-07-01 23:11:03
A inspector that solve my issues is meteor server console. Here is the process I followed to install it:
In your project folder, add the smart package
server-eval
:For Meteor 1.0:
Restart meteor.
crx
Chrome extension file from here.crx
file to extensions page.Check the web inspector out to eval server side code:
In comparison with node-inspector, I have a clearer output.
@juanpastas 2014-12-18 21:03:17
from what I remember it worked with breakpoints, but I am not sure.
@Sabrina Leggett 2014-12-18 21:38:36
do you remember how you set them? via dev tools or incode?
@juanpastas 2014-12-19 01:23:54
dev tools, but don't remember exactly how
@Sergey.Simonchik 2013-02-14 11:07:28
Meteor apps are Node.js apps. When running a Meteor app with the
meteor [run]
command, you can configure theNODE_OPTIONS
environment variable to startnode
in debug mode.Examples of
NODE_OPTIONS
environment variable values:--debug
--debug=47977
- specify a port--debug-brk
- break on the first statement--debug-brk=5858
- specify a port and break on the first statementIf you
export NODE_OPTIONS=--debug
, allmeteor
command run from the same shell will inherit the environment variable. Alternatively, you can enable debugging just for one run, withNODE_OPTIONS="--debug=47977" meteor
.To debug, run
node-inspector
in a different shell, then go tohttp://localhost:8080/debug?port=<the port you specified in NODE_OPTIONS>
, regardless of whatnode-inspector
tells you to run.@Dan Dascalescu 2014-02-12 02:03:00
WebStorm, the powerful IDE free for open source developers, makes it much easier to debug server-side.
I've tested it on Windows, and the configuration was painless - see my answer.
@broth-eu 2013-12-14 10:07:24
I wrote a small meteor package called meteor-inspector which simplifies the use of node-inspector to debug meteor apps. It internally manages the lifecycle of node-inspector and hence, the user does not need to restart the debugger manually after some files have changed.
For more details and concrete usage instructions take a look at https://github.com/broth-eu/meteor-inspector.
@Mason Zhang 2012-07-29 13:15:22
To start node.js in debug mode, I did it this way:
before
add
Here are additional practical steps for your to attach debugger eclipse:
when you start meteor in your meteor app folder, you'll see that "debugger listening on port 5858" in console.
@Jameson Quinn 2012-08-21 12:43:21
if you're using mrt, of course the path to run.js is different.
@Jameson Quinn 2012-08-21 13:35:56
... as in ~/.meteorite/meteors/meteor/meteor/0a148c69d6af9832006a6f6d27cc112ed90cb3e4/app/meteor/
@zVictor 2012-10-11 01:03:46
My files are duplicated in
/usr/lib
and/usr/local/
by unknown reasons. If it doesn't work to you, try editing/usr/local/meteor/app/meteor/run.js
instead of/usr/lib/meteor/app/meteor/run.js
@zVictor 2012-10-11 01:16:19
Thanks, your solution is the easiest I ever found. It doesn't require to be killing process, neither set variables over the command line.
@Nachiket 2012-06-14 18:21:35
I am not sure why it was not working for you.
I am able to use it by following steps on console (Mac).
Above steps are mentioned on https://github.com/dannycoates/node-inspector. It is for attaching node-inspector to running node process.
@Nachiket 2012-07-05 14:44:58
I have tested on Mac only, are you using Mac?
@Gezim 2012-07-10 15:54:18
Yeah, I have a Mac. How do you add the breakpoint in code? What are the exact steps you use for the whole thing?
@Nachiket 2012-07-11 05:15:31
after above (this answer's) steps, I start the inspector. $ node-inspector & opened 127.0.0.1:8080/debug?port=5858 in chrome. I was able to see my files in source tab in webkit-inspector
@Jakub Arnold 2012-10-26 17:50:06
I've tried this, adding both
debugger
and breakpoints in the inspector, but neither of them worked. Any idea why?@quinn 2013-02-25 17:56:29
When look at
ps | grep node
(or similar) make sure you pick the main.js pid to signal, not it's parent node process. This is how I got it to work.@juanpastas 2014-07-01 21:34:33
from what I remember
&
operator does launch process in the background as in Linux.