Particle-cli issues - Error loading module 'serialport'

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