Particle CLI serial error

I am trying to use the Particle CLI to get my device particle ID. DFU successfully flashed new firmware, but with the device in listening mode (blinking blue), and running particle identify, I encountered the following error. This error was reproduced below with particle setup:

 _ __             _   _      _        
| '_ \  __ _ _ __| |_(_) ___| | ___ 
| |_) |/ _` | '__| __| |/ __| |/ _ \
|  __/| (_| | |  | |_| | (__| |  __/
|_|    \__,_|_|   \__|_|\___|_|\___|
                 https://particle.io

> Setup is easy! Let's get started...
> It appears as though you are already logged in as justice@amper.xyz
? Would you like to use this account? Yes
Please reinstall the CLI again using npm install -g particle-cli

! PROTIP: Hold the MODE/SETUP button on your device until it blinks blue!
! PROTIP: Please make sure you are connected to the internet. 

| Now to find your device(s)...(node:6157) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'list' of undefined
    at SerialCommand.findDevices (/usr/local/lib/node_modules/particle-cli/dist/cmd/serial.js:52:14)
    at SetupCommand.findDevice (/usr/local/lib/node_modules/particle-cli/dist/cmd/setup.js:247:10)
    at accountStatus (/usr/local/lib/node_modules/particle-cli/dist/cmd/setup.js:129:4)
    at switchChoice (/usr/local/lib/node_modules/particle-cli/dist/cmd/setup.js:99:5)
    at <anonymous>
(node:6157) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6157) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
\ Now to find your device(s)...

I have tried running that npm command, I have uninstalled and reinstalled particle-cli, I have even uninstalled and reinstalled npm itself, but I continuously get that same error. I have tried different usb ports and the same result.

How do I fix this? This is critical functionality for me and I need this working ASAP.

EDIT: This has been working for me before, and was working Friday. I haven’t touched my machine since then and it stopped working suddenly

NodeJS installed?
Which OS-Version you are trying?

I just reinstalled NodeJs 8.11, and 8.8 was previously installed. macOSX High Sierra.

You’ll run into a lot of trouble using a global install of the CLI under High Sierra. The best way to solve this is:

Remove any old installation. If you get a command not found error, just go to the next step.

sudo npm uninstall -g particle-cli

Then install using the Particle CLI installer:

bash <( curl -sL https://particle.io/install-cli )

Make sure you don’t use npm install -g particle-cli again, or you’ll get back into the broken state. To update the CLI use:

particle update-cli

The reason is a change in permissions in High Sierra. It’s really hard if not impossible to solve using a root-installed CLI. The Mac Particle CLI installer installs as the current user, not as root, to avoid this issue. Sometimes the -g install works for a while under High Sierra, but then if you breathe incorrectly on it, it will be forever broken.

2 Likes

@rickkas7, makes sense. Just tried that and when I try to run anything I get the following:
-bash: /usr/local/bin/particle: No such file or directory

You may need to log back out and log back in. If that doesn’t work, make sure this is at the end of the .profile file in your home directory:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

Opened it and already had that code in there. After logout and login I now get
-bash: particle: command not found

Oh, wait, I see the problem:

sudo rm /usr/local/bin/particle

There’s a symbolic link left over from old install, which is higher on the PATH than the new one in ~/bin.

Sorry about that.

That command didn’t work for me, but when I added the path in my .bash_profile file instead of the .profile file everything appears to be working. Thanks for the help!

2 Likes

Is it possible to add this to the official docs, if not already there? I’ve definitely updated globally several times because that’s what it says in the CLI…