Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chrome dev tools "save" not working while debugging node.js app

While debugging node.js cli script in chrome dev tools (that is possible http://youtu.be/03qGA-GJXjI), I cannot save the changes I made on the fly like I can when I debug normal javascript from a website. I get an error message:

"Debugger.setScriptSource failed. LiveEdit Failure: Failed to compile new version of script: SyntaxError: Unexpected token ["

And then a warning:

Saving of live-edit changes back to source files is disabled by configuration. Change the option "saveLiveEdit" in config.json to enable this feature.

Does anyone know how to fix this? It would be really convenient to debug and edit file and save it while not leaving chrome dev tools.

Thanks.

btw, this is how the config.json looks like, https://github.com/node-inspector/node-inspector/blob/master/config.json. I tried changing "saveLiveEdit" option to true, but still I get the same message "Saving of live-edit changes back to source files is disabled by configuration. Change the option "saveLiveEdit" in config.json to enable this feature."

like image 873
Pavle Lekic Avatar asked Jul 09 '14 17:07

Pavle Lekic


People also ask

Can you debug Node JS application in Chrome DevTools How?

Using Google Chrome DevTools to Debug To start debugging, let's run our application with the --inspect-brk flag. The next step is to head to Chrome, open a new tab, and enter the URL chrome://inspect/ . Click on “Open dedicated DevTools for Node” to start debugging the application.

How do I enable JavaScript debugging in Chrome?

Press the F12 function key in the Chrome browser to launch the JavaScript debugger and then click "Scripts". Choose the JavaScript file on top and place the breakpoint to the debugger for the JavaScript code.


2 Answers

This seemed to work for me. I started 2 shells:

  1. node-inspector --save-live-edit
  2. node --debug app.js

Then go to http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858 on your browser.

Making changes to your code should save it on the hard drive.

like image 194
invalidred Avatar answered Sep 28 '22 20:09

invalidred


You can use the environment variable node-inspector_save-live-edit and set it to true. The environment variable node-inspector_ prefix is scanned by node-inspector.

You can also use $HOME/.node-inspectorrc and store the following:

{ "save-live-edit": true, "preload": false, "hidden": ["node_modules/" ], "nodejs": ["--harmony"] }

like image 34
rainabba Avatar answered Sep 28 '22 20:09

rainabba