How to enable --debug for node.js when starting GeddyJS

GeddyJS is started by running geddy from the root of the project.

I'm having trouble getting GeddyJS to run in node.js with debugging turned on.

getty installs / usr / local / bin / geddy:

  #! / usr / bin / env node
 ...

which I did quickly and changed the shebang line:

  #! / usr / bin / env node --debug
 ...

but this does not work because env cannot find 'node --debug'.

Then I tried to write a shell script to act as an interpreter in the shebang line:

  #! / bin / sh
 exec / usr / bin / env node --debug $@

And this time, the node starts with the debugger turned on, but the paths must be mixed up or the environment must be different, because I get module exceptions:

  $ geddy-debug
 debugger listening on port 5858

 node.js: 201
         throw e;  // process.nextTick error, or 'error' event on first tick
               ^
 Error: Cannot find module '../lib/geddy'
     at Function._resolveFilename (module.js: 332: 11)
     at Function._load (module.js: 279: 25)
     at Module.require (module.js: 354: 17)
     at require (module.js: 370: 17)
     at Object.  (/ usr / local / bin / geddy-debug: 4: 1)
     at Module._compile (module.js: 441: 26)
     at Object..js (module.js: 459: 10)
     at Module.load (module.js: 348: 31)
     at Function._load (module.js: 308: 12)
     at Array.0 (module.js: 479: 10)

This, of course, works great if I'm not trying to enable debugging.

I want to debug in eclipse according to: https://github.com/joyent/node/wiki/Using-Eclipse-as-Node-Applications-Debugger which works fine with node --debug scriptname.js

Any suggestions are welcome.

+1
source share
2 answers

Answering my own question, others can benefit if they see it:

From the project directory, redefine the shebang line and call the interpreter directly to run the geddy script:

/usr/bin/env node --debug /usr/local/bin/geddy

+3
source

There Debugging the Geddy WikiPage with a bit more information.

0
source

Source: https://habr.com/ru/post/910098/


All Articles