Particle-cli issues - Error loading module 'serialport'

Hi all - I believe I have the latest version of particle-cli install as I just used npm install -g particle-cli, but when I try to run particle list (or _particle _anything_ for that matter), I get:

jeremykoerber@Jeremys-MacBook-Air ~ $ particle -v
! Error loading module ‘serialport’: The module '/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release/serialport.node’
was compiled against a different Node.js version using
NODE_MODULE_VERSION 14. This version of Node.js requires
NODE_MODULE_VERSION 51. Please try re-compiling or re-installing
the module (for instance, using npm rebuild ornpm install).
Please reinstall the CLI again using npm install -g particle-cli

I’ve tried all 3 of those suggestions at the bottom of the error, but to no avail. I searched around a while, and wasn’t able to find anything similar. Can anyone help me out with this?

P.S. I’m new here. :slight_smile:

Thanks!
Jeremy

1 Like

I’m having the same trouble. I updated to the latest CLI version, and now nothing works. I upgraded both Node (6.10.2) and npm (4.5.0) to their latest versions, then re-installed the CLI. Still not working (Mac OS 10.12.4). I also updated (or tried to) serialport, but I get that I still have 14, and node wants 48.

After Edit:

I ran the command, sudo npm install -g node-pre-gyp serialport particle-cli and that seems to have fixed it (I saw that suggestion in this post).

3 Likes

Thanks so much for the answer, Ric! Worked for me, too! :smiley:

2 Likes

Thanks @Ric for the help!

I’ve seen a few people with this same problem recently, and I have solved it a few times:

I feel like this bug should be documented.

1 Like

Once again, I foolishly tried to update the cli, since it keeps asking me to do so when I use it. I tried the command you reference, but it didn’t work this time. I tried updating node using brew, but now I can’t seem to get anything to work (including uninstalling the CLI). I now get this error, which I haven’t seen before,

Error: Cannot find module 'semver’
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:2:14)
at Module._compile (module.js:569:30)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)

I’m on macOS Sierra 10.12.5
Any ideas what to try now?

Update:

I fixed this using the suggestions from Stack Overflow (here)

I ran these commands,

sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm
brew uninstall --force node
brew install node

followed by,

npm uninstall -g particle-cli
npm install -g particle-cli

3 Likes

I just use:

sudo npm install -g --unsafe-perm node-pre-gyp npm serialport particle-cli

To solve that problem.

3 Likes

I followed these instructions and worked well for me. Thanks!