How to see node errors?

The OpenShift forums have been retired.
You can still read and search them, but for help, please post a question on Stack Overflow.

I am having difficulty in getting my node app to run.

In ~/nodejs-0.6/logs/node.log I am seeing this:

npm ERR! node -v v0.6.20
npm ERR! npm -v 1.1.37
npm ERR! code ELIFECYCLE
npm ERR! message application-name@0.0.1 start: `node server.js`
npm ERR! message `sh "-c" "node server.js"` failed with 1
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /var/lib/openshift/514fbb775004466ff5000005/app-root/runtime/repo/npm-debug.log
npm ERR! not ok code undefined
npm ERR! not ok code 1

The npm-debug.log isn't much better:

16 error Failed at the application-name@0.0.1 start script.
16 error This is most likely a problem with the application-name package,
16 error not with npm itself.
16 error Tell the author that this fails on your system:
16 error     node server.js
16 error You can get their info via:
16 error     npm owner ls application-name
16 error There is likely additional logging output above.
17 error System Linux 2.6.32-358.2.1.el6.x86_64
18 error command "node" "/usr/bin/npm" "start" "-d"
19 error cwd /var/lib/openshift/514fbb775004466ff5000005/app-root/runtime/repo
20 error node -v v0.6.20
21 error npm -v 1.1.37
22 error code ELIFECYCLE
23 error message application-name@0.0.1 start: `node server.js`
23 error message `sh "-c" "node server.js"` failed with 1
24 verbose exit [ 1, true ]

How can I see the real error? I also tried:

node server.js -e production

It first bombed because my environment variables were not set for some reason (I use node.env) but when I manually set them in bash I get this:

events.js:48
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: listen EACCES
    at errnoException (net.js:670:11)
    at Array.0 (net.js:756:28)
    at EventEmitter._tickCallback (node.js:190:38)

This looks like actually node output but I don't understand why it differs from node.log.

I am having trouble tracking down the real cause of the problem. Only thing I know to do is to comment out my code line by line but this isn't really feasible.

Thanks in advance.

@preagrarius, that error has to do with the interface or port you are binding to.
OpenShift has restrictions on that -- for the port # assuming you are using 8080 since
requests to this server would then be proxied from the front end router (apache).
And the interface/ip you should be using is the value of the env variable:
OPENSHIFT_NODEJS_IP or OPENSHIFT_INTERNAL_IP.

If this is an 'express' app, you could do something like:

 
app = express();  
var port = process.env.OPENSHIFT_NODEJS_PORT ||  process.env.OPENSHIFT_INTERNAL_PORT || 8080;  
var ipaddr = process.env.OPENSHIFT_NODEJS_IP || process.env.OPENSHIFT_INTERNAL_IP;  
app.listen(port, ipaddr);  

HTH

I like adding || 'localhost';; to the end of the ipaddr line, so I can run and debug my applications locally as well:

var ipaddr = process.env.OPENSHIFT_NODEJS_IP || process.env.OPENSHIFT_INTERNAL_IP || 'localhost';

That did the trick, thanks!