How to change it from 5858 to 7000, for example?
You can use --debug option:
node --debug=7000 app.js
You can use --inspect option for latest node >= v8
node --inspect=7000 app.js
https://nodejs.org/en/docs/inspector/
For nodejs version >= v8 use this:
node --inspect=7000 --inspect-brk app.js
Related
When I try to use debugger in node to open debugger, I get an error 'Timeout (2000) waiting for 127.0.0.1:9229 to be free'. How can I resolve this and run the debugger correctly ?
function foo() {
var a = 5;
debugger
console.log(a)
}
foo()
I have already tried changing the port using node inspect --port=9230 app.js and it doesn't work.
Try this:
node --inspect-brk app.js
replace app.js with your file name that you want to run, and you can insert your additional command alongside with this line.
I had the same problem, it took me hours to figure it out...
Run the following command:
node inspect --port=9228 file.js
I had the same issue by using VS Code. VS code document helps. Replace program.js with your js file name.
https://code.visualstudio.com/docs/nodejs/nodejs-debugging
if the program should not start running but must wait for the debugger to attach:
node --inspect-brk program.js
Use node --inspect-brk {js file name} instead. It will work.
--inspect-brk=[host:port]
Enable inspector agent
2.Bind to address or hostname host (default:127.0.0.1)
3.Listen on port port (default: 9229)
4.Break before user code starts
I think the issue here is the command you give to node, it should be node --inspect..
You are missing the -- in front of inspect :)
Install
npm install --global node-inspect
Then
node-inspect script.js
Ref: https://www.npmjs.com/package/node-inspect
I've started my application on my server with pm2:
pm2 start /path/lib/start-server.js --name="cdl-debug" -- --inspect
Which would be equivalent to node /path/lib/start-server.js --inspect
The application starts and runs, although I see no notice in the logs about any debugging like explained here
I've opened up port 9229 in the firewall and setup my WebStorm debug config with Attach to Node.js/Chrome like so:
Then when I run the debugger it tries to connect for a while and finally fails with the message: Connection timed out. No further information.
Is there something else I should do? The WebStorm documentation doesn't mention much about the required setup on the server.
When running node /path/lib/start-server.js --inspect, you are passing --inspect to your application, not to Node.js. As a result, debugger is not started. You need to make sure to pass --inspect-brk to Node.js in order to debug your app:
node --inspect-brk /path/lib/start-server.js
You can specify --inspect-brk in your pm2 process.json, like
"node_args": [
"--inspect-brk=7000"
]
and then start your app with pm2 start process.json
I'm facing an error:
Starting inspector on 127.0.0.1:9229 failed: address already in use
How can I resolve this error?
You can do it this way:
node --debug=5412 app.js
You can also use --inspect option for node version >= v8
node --inspect=5622 app.js
See for More Help.
use param "--inspect"
node --inspect=0.0.0.0:[your port] app.js
When I debug my node rest api, I try to use node-inspector
node-inspector
node --debug server.js
This way I can debug my api using localhost:3000/api...
If I use node-debug, there's no way. It doens't start port 3000.
However my code is ES6, so in my current debug my code is transpiled by Babel.
I've tried to use babel-node-debug but It seems too be the same situation I had with node-debug. I can see ES6 code, but I'm not able to debug through port 3000.
Any workaround?
The options for babel-node (included in the babel-cli package) are the same as for node.
Specify the port for babel-node
babel-node --debug-brk=8010 test.js
Start node-inspector
node-inspector
Navigate to the node-inspector URL, passing the same port as a query parameter
http://127.0.0.1:8080/?port=8010
I have tried this and it works well for me.
Disclaimer - I found this information here:
https://github.com/CrabDude/babel-node-debug/issues/6
I am using brunch.io with a custom server app.coffee.
This is what my brunch-config.coffee entry looks like:
server:
path: 'app.coffee'
port: 3333
base: '/'
I want to use node's default debugger, but when I type debugger anywhere in my app.coffee, script execution doesn't stop. My debugger statement is simply ignored.
How can I make brunch run my server so that debugger statements are not ignored but pause script execution?
Brunch version: 1.7.18
Coffee version: 1.7.1
Node version: 0.10.30
Thanks for your time!
To use the debugger, it would be best to run brunch watch and your node app in separate terminal instances.
Just run brunch watch without the -s/--server option, and then separately run something like:
coffee --nodejs --debug app.coffee