[ISSUE] SerialPort.list is not a function

I reinstalled particle-cli in an attempt to fix path issues in MacOS Monterey and now I’m in a world of trouble:

  • If I install particle-cli using the recommended method (straight from particle using curl), the particle command is found but produces no output in terminal.
  • If I install particle-cli using npm install -g particle-cli I get output, but none of the serial commands work: they all output SerialPort.list is not a function.

I uninstalled and reinstalled through every path mentioned here (including running sudo npm install -g --unsafe-perm particle-cli and running from source) to no avail.

Thank you for your help!

Are you on one of the newer ARM macs? If so, you're probably running into this issue:

I’ll note that I’m currently struggling with the same issue installing on a fresh Ubuntu machine (18.04.3 LTS). I’ve gotten everything to work in the past on an identical machine so I’m wondering if there’s some version mismatch somewhere.

Does it work if you try the particle-cli managed by neopo?

On Arch Linux the serial commands still work for me:

$ neopo particle serial list

I’m using version 3.1.0 by the way:

$ particle --version
3.1.0

the neopo version (neopo particle serial list) works for me! I suppose I could change all my scripts over to just use neopo, no skin off my back, personally. Happy to help debug the normal particle install however I can for the sake of other folk though.

My particle version is the same, 3.1.0

EDIT: looks like installing neopo also fixed this issue when running the particle cli directly! Any idea what the difference in install approach might be to cause one to work but not the other?

EDIT2: could it be particle usb configure that is fixing something? I notice you do that in the neopo install script but that was not something I’ve ever ran to my knowledge

This is mostly because running particle will still give you the neopo wrapper, which applies some fixes to the environment particle-cli runs as a subprocess in.

This only copies the udev rules file on Linux to allow non-root access to Particle devices over serial/DFU.

1 Like

Got it - I’ll just continue to use neopo then! Thanks for your work on that project :slight_smile:

1 Like

I’ll also note separately as someone who has an M1 mac on Monterrey that the particle cli as installed by workbench worked perfectly for me - I think it properly contextualizes it in rosetta mode when it runs that way? Either way I’d recommend trying to install via workbench if you haven’t tried that and neopo doesn’t work for you @maximiliaan or if for whatever reason you don’t want to go that route.

Unfortunately this issue is still present/relevant:

[jaap@jaap ~ ]$ npm list -g
/usr/lib
+-- corepack@0.17.2
+-- http-server@0.12.1
+-- node-gyp@9.3.1
+-- nopt@7.1.0
+-- npm@8.19.2
+-- particle-cli@3.7.0
+-- particle-usb@2.2.0
+-- root@3.2.0
+-- semver@7.3.8
+-- serialport@11.0.0
`-- yarn@1.22.19

[jaap@jaap ~ ]$ particle serial list     
SerialPort.list is not a function

For those interested, a possible workaround is to use the particle-cli from source:

[jaap@jaap ~/src/particle-cli ]$ git remote -v
origin  https://github.com/particle-iot/particle-cli.git (fetch)
origin  https://github.com/particle-iot/particle-cli.git (push)
[jaap@jaap ~/src/particle-cli ]$ git log -1
commit e5fa7e43cc4d09f7128c01f7d1f94f3ad6b01783 (HEAD -> master, origin/master, origin/HEAD)
Merge: 932454c0 e5e7687b
Author: Keerthy Amisagadda <48732259+keeramis@users.noreply.github.com>
Date:   Tue May 23 00:23:46 2023 +0530

    Merge pull request #641 from particle-iot/feature/sc-118328/compile-source-before-bundle
    
    Feature/sc 118328/compile source before bundle
[jaap@jaap ~/src/particle-cli ]$ npm start -- serial list

> particle-cli@3.10.2 start
> node ./src/index.js serial list

Found 1 device connected via serial:
/dev/ttyACM0 - B5 SoM - <hex>
[jaap@jaap ~/src/particle-cli ]$ npm list | grep -i serialport
+-- serialport@9.2.8