SerialCommand.js Error: Module version mismatch

Hi I’m new to using node/npm, and need to configure new Photons/Electron over USB.
When I follow the instruction with newly installed node.js/Win10 I get the following when I execute

particle setup.

SerialCommand.js Error: Module version mismatch. Expected 48, got 46.

node -v
npm -v

I think its something to do with a mismatched versions, but I can’t see how I rebuild.
Many thanks for any insight.

Have you used the Windows CLI Installer?

Yes - tried it this morning. It doesn’t appear to be referenced anywhere in the documentation, but was listed in a Sept5 posting.

Just wondering if there are any other suggestions.
It seems like this is an internal consistency error with the downloaded environment. I have spent about 4hrs total trying to get this environment up, from researching, looking for more uptodate examples, and looking at other similar errors and trying out potential solutions.
many thanks

Does npm install -g serialport or npm update -g serialport change anything?

@ScruffR I just did a fresh install of Windows 10.

I installed Node 7.

I installed the Particle CLI via the Windows Installer and got a bunch of errors, one of those first errors was the Serial issue others were also having.

I just tried to run the npm update -g serialport in the Node Js Command window but it throws a bunch of errors also. Should I not be using Node 7.0?

Do the errors make any sense to you?

C:\Users\RWB>npm install -g serialport
C:\Users\RWB\AppData\Roaming\npm\serialport-list -> C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport\bin\serialport-list.js
C:\Users\RWB\AppData\Roaming\npm\serialport-term -> C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport\bin\serialport-terminal.js

> serialport@4.0.3 install C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download:
node-pre-gyp ERR! Pre-built binaries not found for serialport@4.0.3 and node@7.0.0 (node-v51 ABI) (falling back to source compile with node-gyp)

C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean )  else (node "" clean )

C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport\build\Release\serialport.node --module_name=serialport --module_path=C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport\build\Release )  else (node "" configure --fallback-to-build --module=C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport\build\Release\serialport.node --module_name=serialport --module_path=C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport\build\Release )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:449:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:404:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:111:15)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\Users\\RWB\\AppData\\Roaming\\npm\\node_modules\\serialport\\build\\Release\\serialport.node" "--module_name=serialport" "--module_path=C:\\Users\\RWB\\AppData\\Roaming\\npm\\node_modules\\serialport\\build\\Release"
gyp ERR! cwd C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport
gyp ERR! node -v v7.0.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport\build\Release\serialport.node --module_name=serialport --module_path=C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport\build\Release' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:877:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Windows_NT 10.0.14393
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\RWB\\AppData\\Roaming\\npm\\node_modules\\serialport\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport
node-pre-gyp ERR! node -v v7.0.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.30
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport\build\Release\serialport.node --module_name=serialport --module_path=C:\Users\RWB\AppData\Roaming\npm\node_modules\serialport\build\Release' (1)
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "serialport"
npm ERR! node v7.0.0
npm ERR! npm  v3.10.8

npm ERR! serialport@4.0.3 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@4.0.3 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs serialport
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls serialport
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\RWB\npm-debug.log


The problem with serialport is that it might lag behind the version of node (at least the prebuilt binaries).
So for some packages it’s best to wait with upgrading node till they are upgraded too (or have a compiler installed to build your own from source).

@ScruffR I deleted Node 7.0 and installed Node 6.9.1 and then ran the Particle Windows CLI installer and it’s finally working!! :smiley:

I’m am glad it forced me to start with a fresh copy of Windows 10 since I cleared out tons of old files I no longer use.

Hopefully the Particle Dev install works without a hitch also now :smile:

1 Like

So just wondering is the recommendation to do a fresh install of Windows10?

Is there no way to clean out the node and npm and start again.?

I only did a fresh install of Windows 10 because nothing else I tried allowed me to run Particle CLI or Particle DEV.

I did something to the file structure when I was trying to install the Google Cloud tutorial which prevented the Particle applications from running.

The last thing I wanted to do was wipe the laptop clean, but in the end, I’m happy I’ve updated, and the computer is clean again.

So…I updated node yesterday to 6.9.1 and no longer have access to the “serial” command. When I do

[Toms-MacBook-Pro:~] tom% particle help
Error loading command /usr/local/lib/node_modules/particle-cli/commands/SerialCommand.js Error: Module version mismatch. Expected 48, got 46.

Node and npm seem to be current:

[Toms-MacBook-Pro:~] tom% node -v
[Toms-MacBook-Pro:~] tom% npm -v

Trying to update serialport seemingly does nothing:

[Toms-MacBook-Pro:~] tom% sudo npm update -g serialport
[Toms-MacBook-Pro:~] tom%

I often use the particle serial command to monitor troubleshooting output from my device. So even though I can likely flash via DFU, I really want the serial command to work again. Thoughts?

should I uninstall node and npm and re-install both?

Try reinstalling the CLI first, that might be sufficient.

@Moors7, looks like that’s going to do it. I had to uninstall first with the following command:

npm uninstall -g particle-cli

and then install with:

npm install -g particle-cli

and I appear to be back in business–at least the command is now listed and it seems to be performing as expected so far.

I don’t know what I did to screw things up, other than upgrade node.js. If that’s a likely cause, then perhaps the documentation should suggest the above procedure. I have noticed others experiencing the same issue.

As always, thank you for your quick advice!

1 Like

Hey that worked for me as well now.
I made sure I did it in Admin privilege as well.

1 Like