PhinCo / node-jlink

nodejs interface for Segger jLinkexe
MIT License
4 stars 3 forks source link

"Error: spawn JlinkExe ENOENT" #3

Open josejsarmento opened 2 years ago

josejsarmento commented 2 years ago

Working on a Raspberry Pi 4, Raspberry Pi OS lite 64, JLink V7.64e, npm 8.8.0 I have installed the NRFJprog terminal tools and JLinkExe for Linux Arm 64.

Using any of the instructions in the README, such as the following program.js:

var jlink = require("@connectedyard/node-jlink");      
jlink.reset(); // nrfjprog --reset

results in the following error:

> start
> node program.js

node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: spawn JlinkExe ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn JlinkExe',
  path: 'JlinkExe',
  spawnargs: [
    '-device',
    'nrf51822',
    '-if',
    'swd',
    '-speed',
    '4000',
    '-autoconnect',
    '1'
  ]
}

Typing JLinkExe directly on the terminal opens the program, so it's correctly installed. Is this because the module is trying to call JlinkExe with a lowercase "L" instead of uppercase? I think this is done in line 43 of ./lib/jlinkexe.js

stavrt commented 12 months ago

Yup. I was testing this and seems like it wont work well. In the node_modules folder, you can edit jlinkexe.js

The code should be changed to this:

else if( process.platform.indexOf('linux') !== -1 ){ return "JLinkExe"; }