Search code examples
node.jscloud9-ideraspberry-pi2

Cloud9 on Raspberry Pi 2 debug with sudo


I installed Cloud9 on Raspberry Pi 2 and now I am trying to create Node.js classic "Hello world" app which will be blinking the LED connected to GPIO. I found this library to work with GPIO https://github.com/jperkin/node-rpio which is working great. But the script must be executed with sudo to be able to work with pins. So in Cloud9 I must use the bash panel and write "sudo node ./script.js". Is there some way how to create/modify runner to use sudo command?


Solution

  • The solution is to create custom runner with this json:

    {
      "cmd": [
        "bash",
        "-c",
        "sudo node ${debug?--nocrankshaft} ${debug?--nolazy} ${debug?--debug-brk=15454} $file $args"
      ],
      "debugger": "v8",
      "debugport": 15454,
      "selector": "source.js",
    }
    

    Node that it not contains the line from the original runner which was for node v0.x because I am using newer.

    "${debug?`node --version | grep -vqE \"v0\\..\\.\" && echo --nodead_code_elimination`}",