This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

pc-ble-driver-js test code dfu.js with electron module error

Hello I am trying to make an electron application which is based from the 'pc-ble-driver-js' module for testing pupose for production development with nordic product

I am using NRF52 Development kit to do DFU to other device. When I run 'node dfu.js <mac_address> <path_fw_zip_file>'

it runs fine and do DFU perfectly when I am in 'pc-ble-driver-js' folder.

I change package.json:

"main": "main.js",

"scripts": { "start": "electron ." }

"devDependencies": { "electron": "1.4.15" }

and so

main.js : https://gist.github.com/InKyu0317/e82ae11f2a5375e28d05f0a44914444a

index.html: https://gist.github.com/InKyu0317/f969aadad6ea78a9eeec21fccebfafde

^ this do require(dfu.js) in script tag, maybe this occur the problem

dfu.js: https://gist.github.com/InKyu0317/1231d419488a5c437ed36a2ed3e4fedc

^ .index .setup file are given from the original 'pc-ble-driver-js' code

error:

This is the error I get when I do 'npm start' to run the app.

If anyone had same problem or know why it happens, please give some suggestion or solution if it is okay.

Thank you all of you reading my question.

  • Hi,

    It happens because you try to run a native node module (pc-ble-driver-js) in a runtime that it was not compiled for. It was built for node command line, and you try to use it through electron.

    So, you must recompile pc-ble-driver-js for the correct runtime. According to our developers, copying the .npmrc from pc-nrfconnect-core into the root folder of your project should do the trick:

    https://github.com/NordicSemiconductor/pc-nrfconnect-core/blob/master/.npmrc

    Regards,
    Terje

  • Thank you for reply, Can you provide me little more hint about 'recompile'. 'I tried 'npm install' and 'npm start' after i put .npmrc, it didn't change the result. I still have same error. Thank you.