Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"node --debug" and "node --debug-brk" are invalid

I have updated the node (v8.1.2). When I want to debug my previous test project in nodejs using NTVS (in visual studio 2017) I've gotten the following error:

StandardError: (node:5292) [DEP0062] DeprecationWarning: node --debug and node --debug-brk are invalid. Please use node --inspect or node --inspect-brk instead.

The problem is clear. The tool try to run the node --debug to start the project.

The question is, how can I change node --debug to node --inspect in Visual Studio 2017 to running the test?

Also, I should have mentioned that I can't solve the problem by adding --inspect into the Script Arguments.

like image 240
OmG Avatar asked Jun 26 '17 03:06

OmG


3 Answers

If anyone is still having this issue, in your wdio.conf.js replace debug: true, execArgv: ['--debug=127.0.0.1:5859'] with inspect: true, execArgv: ['--inspect=127.0.0.1:5859'].

like image 59
enncheema Avatar answered Oct 20 '22 06:10

enncheema


You can use Chrome's DevTools to debug as below:

  1. Start Node with --inspect option ... e.g. $node --inspect app.js. You should see a console printout something like

    Debugger listening on ws://127.0.0.1:9229/2558baab-1141-4db3-8d10-771586f876a6

  2. Open Chrome browser and browse to chrome://inspect. Click on "Open dedicated DevTools for Node" link.

like image 2
kchoi Avatar answered Oct 20 '22 05:10

kchoi


I did this:
1. mv /usr/local/bin/node /usr/local/bin/node_bin
2. echo > /usr/local/bin/node
3. editor /usr/local/bin/node
insert script:

#!/bin/bash
## the script converting parameters for nodejs new version
##
new_name="node_bin";
eval _options="(" $(echo -e $@) ")"
_node=$(whereis -b $new_name|awk '/^'$new_name':/{print $2}');                                                                              
eval _version="(" $(echo -e $($_node --version|sed 's/[^0-9]/ /g')) ")";                                                                    
# local values                                                                                                                              
old_options=( "--debug" "--debug-brk" );                                                                                                    
new_options=( "--inspect" "--inspect-brk" );                                                                                                
_opt=();                                                                                                                                    

function filtr() {                                                                                                                          
    _opt=${_options[@]};                                                                                                                    
    for ((get_i=0; get_i != ${#old_options[@]}; get_i++))                                                                                   
        do                                                                                                                                  
        if [ ${new_options[$get_i]} = "" ];
            then
                _opt=${_opt[@]};
            else
                _opt=$( echo -e ${_opt[@]}|sed 's/'${old_options[$get_i]}'/'${new_options[$get_i]}'/g');
        fi
    done

}

function convert() {

if [ $(echo -e ${#_options[@]}) = 0 ];
    then 
        $_node;
    else
     filtr;

        $_node $(echo -e ${_opt[@]})
fi
exit 0;
}

if (( ${_version[0]} >= 7 ));
 then
   convert;
fi
exit 0;
  1. chmod ugo+x /usr/local/bin/node
    I will not say that the decision is elegant, but it helped me.
like image 2
Valery Bersenev Avatar answered Oct 20 '22 05:10

Valery Bersenev