[SOLVED] Can't Flash Binary from CLI on MacOS, SerialCommand.js Module Version Mismatch Error, "Expected 48, got 46."

I am unable to flash binary from the CLI on MacOS. I have attempted to reinstall and update both NodeJS, particle-cli, as well as have used nvm to attempt to run this with different versions of node, and I am getting the same message:

$ particle flash --serial electron_firmware_1478487240813.bin
Error loading command /usr/local/lib/node_modules/particle-cli/commands/SerialCommand.js Error: Module version mismatch. Expected 48, got 46.
return serial.flashDevice.apply(serial, arguments);

TypeError: Cannot read property ‘flashDevice’ of undefined
at Object.extend.flashYModem (/usr/local/lib/node_modules/particle-cli/commands/FlashCommand.js:146:16)
at Object.extend.flashSwitch (/usr/local/lib/node_modules/particle-cli/commands/FlashCommand.js:122:18)
at Object.BaseCommand.runCommand (/usr/local/lib/node_modules/particle-cli/commands/BaseCommand.js:108:17)
at Object.Interpreter.runCommand (/usr/local/lib/node_modules/particle-cli/lib/interpreter.js:100:13)
at Object.Interpreter.handle (/usr/local/lib/node_modules/particle-cli/lib/interpreter.js:56:18)
at Object. (/usr/local/lib/node_modules/particle-cli/bin/particle.js:20:5)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)

Any thoughts?

What if you try using dfu-util instead?

particle flash --usb electron_firmware_1478487240813.bin

Well, that does get me the end goal, which is to flash the device, so thank you for that.

That being said, I still get some errors - e.g the, “Expected 48 got 46” error. I’m bothered by the fact that there is something screwy with NodeJS-particle-cli when the last time I worked with this about a month ago, there were no problems. Could it be that the most recent update of NodeJS is not compatible with particle-cli or something?

Error loading command /usr/local/lib/node_modules/particle-cli/commands/SerialCommand.js Error: Module version mismatch. Expected 48, got 46.
Found DFU device 2b04:d00a
checking file electron_firmware_1478487240813.bin
spawning dfu-util -d 2b04:d00a -a 0 -i 0 -s 0x08080000:leave -D electron_firmware_1478487240813.bin
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Deducing device DFU version from functional descriptor length
Opening DFU capable USB device…
ID 2b04:d00a
Run-time device DFU version 011a
Claiming USB DFU Interface…
Setting Alternate Setting #0
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
DfuSe interface name: "Internal Flash "
Downloading to address = 0x08080000, size = 23456
Download [=========================] 100% 23456 bytes
Download done.
File downloaded successfully

Flash success!

1 Like

This error is caused by an issue with serialport, and is because a serialport binary for your version of node could not be found.

What happens if you try reinstalling Particle-cli using this command:

sudo npm install -g node-pre-gyp npm serialport particle-cli
1 Like

Please see the GitHub gist showing the terminal output:


It looks like it was successfully reinstalled. Do you still get the same error when you try to do a serial command?

1 Like

Since I was able to accomplish uploading my firmware via DFU, I am moving on to my next issue, and currently working on getting data sent to the Google Cloud via the Particle Integration, re:


I will go back and connect my device to serial later today.

1 Like

Thread is quite old but for others having this issue I can confirm that the above command fixes it. I was facing this issue after updating my node.js installation on Windows 10 for another project and suddenly my Particle CLI started reporting errors. Running the install command mentioned above fixed it right away :smile: