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
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 want to run more than one MEAN js 0.4.2 project using grunt.
First project is running properly by second project giving below error:-
[nodemon] starting `node --debug server.js`
Fatal error: Port 35729 is already in use by another process.
Warning: Use --force to continue.
change port in /config/env/default.js
port: process.env.PORT || 3002,
Please help.I have changed default port(/config/env/default.js) from 3000 to 3002 but still giving same error.
Issue is with the nodemon, two instances of nodemon tries to run on same port.
Try to run
node server.js
Or,
you can try to configure nodemon as well.
https://github.com/ChrisWren/grunt-nodemon/issues/21#issuecomment-28116032
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
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
I've installed node-inspector, and have started it with node.
When I try to start debugging mode with --debug-brk, it still errors out (it's this error I'm trying to debug)
It does not break on the first line...
$ node --debug-brk app.js
debugger listening on port 5858
/base_controller.js:59
files.forEach(function(file) {
^
TypeError: Cannot call method 'forEach' of undefined
at Object.oncomplete (/base_controller.js:59:9)
installed node-inspector : https://github.com/node-inspector/node-inspector
try below steps:
first: node --debug-brk app.js
second:node-inspector
then:
open a new winow in chrome,open url:
http://localhost:8080/debug?port=5858
you can debug your code now !
Maybe you are not running the latest version (it happened to me). Please do
$ node
> process.version
That should give you the last version. You can update here: http://nodejs.org/