Particle-cli - Mac

I was making MARS Rover. Spending time messing round. Making Reboot.
Uninstall Particle-Cli and install the latest Node JS

npm WARN checkPermissions Missing write access to /Users/xxxxx/.npm-packages/lib/node_modules/particle-cli/node_modules/commander
npm WARN checkPermissions Missing write access to /Users/xxxxx/.npm-packages/lib/node_modules/particle-cli/node_modules
npm WARN checkPermissions Missing write access to /Users/xxxxx/.npm-packages/lib/node_modules/particle-cli/node_modules/inquirer/node_modules
npm WARN checkPermissions Missing write access to /Users/xxxxx/.npm-packages/lib/node_modules/particle-cli/node_modules/particle-api-js/node_modules
npm WARN checkPermissions Missing write access to /Users/xxxxx/.npm-packages/lib/node_modules/particle-cli/node_modules/request/node_modules
npm WARN checkPermissions Missing write access to /Users/xxxxx/.npm-packages/lib/node_modules/particle-cli/node_modules/string-width/node_modules
npm WARN checkPermissions Missing write access to /Users/xxxxx/.npm-packages/lib/node_modules/particle-cli/node_modules/wrap-ansi/node_modules
npm ERR! path /Users/xxxxx/.npm-packages/lib/node_modules/particle-cli/node_modules/commander
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/xxxxx/.npm-packages/lib/node_modules/particle-cli/node_modules/commander'
npm ERR!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, access '/Users/xxxxx/.npm-packages/lib/node_modules/particle-cli/node_modules/commander'
npm ERR!     at Error (native)
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/Users/xxxxx/.npm-packages/lib/node_modules/particle-cli/node_modules/commander' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xxxxx/.npm/_logs/2017-07-08T08_49_07_031Z-debug.log

npm WARN excluding symbolic link test/server/static/ie8-polyfill.js -> ../../../ie8-polyfill.js
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN excluding symbolic link test/server/static/ie8-polyfill.js -> ../../../ie8-polyfill.js

and sudo npm install -g particle-cli

$ particle
-bash: particle: command not found

What OS are you running on?

macOS Sierra 10.12.5.

You might need to follow this tutorial to fix the npm issue: https://docs.npmjs.com/getting-started/fixing-npm-permissions

1 Like

Have you tried:

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

This always works for me.

4 Likes

The thing that worked for me:

Use Homebrew to install node, then the command from @nrobinson2000

Michaels-MacBook-Pro:~ Mike$ brew install node
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core, caskroom/cask).
==> Updated Formulae
ammonite-repl flake8 imagemagick rakudo-star whois
assimp gnupg imagemagick@6 suite-sparse
bind gnupg@1.4 paket terragrunt
caddy gnuplot pgbadger typescript
ffmpeg heroku planck vips

Warning: node 8.2.1 is already installed
Michaels-MacBook-Pro:~ Mike$ particle
! Error loading module 'serialport': Could not locate the bindings file. Tried:
→ /usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/serialport.node
→ /usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Debug/serialport.node
→ /usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release/serialport.node
→ /usr/local/lib/node_modules/particle-cli/node_modules/serialport/out/Debug/serialport.node
→ /usr/local/lib/node_modules/particle-cli/node_modules/serialport/Debug/serialport.node
→ /usr/local/lib/node_modules/particle-cli/node_modules/serialport/out/Release/serialport.node
→ /usr/local/lib/node_modules/particle-cli/node_modules/serialport/Release/serialport.node
→ /usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/default/serialport.node
→ /usr/local/lib/node_modules/particle-cli/node_modules/serialport/compiled/6.11.1/darwin/x64/serialport.node
Please reinstall the CLI again using npm install -g particle-cli
Michaels-MacBook-Pro:~ Mike$ sudo npm install -g --unsafe-perm node-pre-gyp npm serialport particle-cli
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
/usr/local/bin/node-pre-gyp -> /usr/local/lib/node_modules/node-pre-gyp/bin/node-pre-gyp
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/serialport-list -> /usr/local/lib/node_modules/serialport/bin/serialport-list.js
/usr/local/bin/serialport-term -> /usr/local/lib/node_modules/serialport/bin/serialport-terminal.js
/usr/local/bin/particle -> /usr/local/lib/node_modules/particle-cli/bin/particle.js

serialport@4.0.7 install /usr/local/lib/node_modules/serialport
node-pre-gyp install --fallback-to-build

node-pre-gyp info it worked if it ends with ok
node-pre-gyp verb cli [ '/usr/local/bin/node',
node-pre-gyp verb cli '/usr/local/lib/node_modules/serialport/node_modules/.bin/node-pre-gyp',
node-pre-gyp verb cli 'install',
node-pre-gyp verb cli '--fallback-to-build' ]
node-pre-gyp info using node-pre-gyp@0.6.32
node-pre-gyp info using node@6.11.1 | darwin | x64
node-pre-gyp verb command install
node-pre-gyp info check checked for "/usr/local/lib/node_modules/serialport/build/Release/serialport.node" (not found)
node-pre-gyp http GET https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v48-darwin-x64.tar.gz
node-pre-gyp http 200 https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v48-darwin-x64.tar.gz
node-pre-gyp info install unpacking .deps/
node-pre-gyp info install unpacking .deps/Release/
node-pre-gyp info install unpacking .deps/Release/obj.target/
node-pre-gyp info install unpacking .deps/Release/obj.target/serialport/
node-pre-gyp info install unpacking .deps/Release/obj.target/serialport/src/
node-pre-gyp info install unpacking .deps/Release/obj.target/serialport/src/serialport.o.d
node-pre-gyp info install unpacking .deps/Release/obj.target/serialport/src/serialport_poller.o.d
node-pre-gyp info install unpacking .deps/Release/obj.target/serialport/src/serialport_unix.o.d
node-pre-gyp info install unpacking .deps/Release/serialport.node.d
node-pre-gyp info install unpacking obj.target/
node-pre-gyp info install unpacking obj.target/serialport/
node-pre-gyp info install unpacking obj.target/serialport/src/
node-pre-gyp info install unpacking obj.target/serialport/src/serialport.o
node-pre-gyp info install unpacking obj.target/serialport/src/serialport_poller.o
node-pre-gyp info install unpacking obj.target/serialport/src/serialport_unix.o
node-pre-gyp info install unpacking serialport.node
node-pre-gyp info tarball done parsing tarball
node-pre-gyp info validate Running test command: '/usr/local/bin/node --eval 'require('/usr/local/lib/node_modules/serialport/build/Release/serialport.node')''
[serialport] Success: "/usr/local/lib/node_modules/serialport/build/Release/serialport.node" is installed via remote
node-pre-gyp info ok

  • node-pre-gyp@0.6.36
  • npm@5.3.0
  • serialport@4.0.7
  • particle-cli@1.23.1
    added 137 packages, removed 249 packages, updated 105 packages and moved 7 packages in 25.806s
    Michaels-MacBook-Pro:~ Mike$ particle

Welcome to the Particle Command line utility!
Version 1.23.1
GitHub - particle-iot/particle-cli: Command Line Interface for Particle Cloud and devices

Usage: particle <command_name>
Common Commands:

setup, list, call, get, device, identify, flash, subscribe
compile, monitor, login, logout, help, library

Less Common Commands:
token, binary, cloud, config, function, keys, serial, udp
update, variable, webhook, wireless

For more information Run: particle help <command_name>

Michaels-MacBook-Pro:~ Mike$

1 Like

I cannot get “Particle cli” to work on my new MacBook Air. On my previous Macs it works perfectly!

First, I must say that I am not a professional programmer. I have only a basic understanding of Unix/Linux…

I know this is an old thread, but I now have this problem on this new Mac:

MacBook Air (M1, 2020)
Mac OS Big Sur v. 11.6.2

I installed Node.js and npm successfully with the download package from the Node website

node -v
v16.14.0

npm -v
8.3.1

I tried to follow and apply all tips above but after installing Particle package, I could not start it…

The last command I tried is this:

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

Result:

PARTICLE CLI SETUP...

                                   :                                    
                                   :                                    
                                  :::                                   
                      :           :::           :                       
                       :::        :::        :::                        
                         ::::     :::     ::::                          
                          ::::::       ::::::                           
                           :::::::::::::::::                            
                             :::::::::::::                              
                    :::::::   :::::::::::   :::::::                     
                    :::::::   :::::::::::   :::::::                     
                             :::::::::::::                              
                           ::::::::.::::::::                            
                          ::::::       ::::::                           
                         ::::     :::     ::::                          
                       :::        :::        :::                        
                      :           :::           :                       
                                  :::                                   
                                   :                                    
                                                                        
:::: Installing the Particle CLI for darwin to "/Users/kampendaal/bin/particle"
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
(23) Failed writing body
gunzip: (stdin): unexpected end of file
:::: Done!
:::: Installing dependencies
:::: Done!
:::: Success!
:::: The Particle CLI has been installed to: "/Users/kampendaal/bin"
:::: Your "/Users/kampendaal/.bash_profile" file has been updated to properly set $PATH
:::: If you previously installed the CLI with npm, run "npm uninstall -g particle-cli"

************************************************************************
** YOU MUST CLOSE AND REOPEN YOUR TERMINAL BEFORE CHANGES TAKE EFFECT **
************************************************************************

When I try “particle login”, the prompt returns without any reaction…

Meanwhile my Mac was downloading and installing the “Xcode developer tools” (as mentioned in the above output… Do I even need this software for Particle CLI?)

After Xcode install was done, I tried once again to install Particle CLI:

MacBook-Air:~ kampendaal$ bash <( curl -sL https://particle.io/install-cli )

PARTICLE CLI SETUP...

                                   :                                    
                                   :                                    
                                  :::                                   
                      :           :::           :                       
                       :::        :::        :::                        
                         ::::     :::     ::::                          
                          ::::::       ::::::                           
                           :::::::::::::::::                            
                             :::::::::::::                              
                    :::::::   :::::::::::   :::::::                     
                    :::::::   :::::::::::   :::::::                     
                             :::::::::::::                              
                           ::::::::.::::::::                            
                          ::::::       ::::::                           
                         ::::     :::     ::::                          
                       :::        :::        :::                        
                      :           :::           :                       
                                  :::                                   
                                   :                                    
                                                                        
:::: Installing the Particle CLI for darwin to "/Users/kampendaal/bin/particle"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
KeyError: 'arm'
gunzip: (stdin): unexpected end of file
:::: Done!
:::: Installing dependencies
:::: Done!
:::: Success!
:::: The Particle CLI has been installed to: "/Users/kampendaal/bin"
:::: Your "/Users/kampendaal/.bash_profile" file has been updated to properly set $PATH
:::: If you previously installed the CLI with npm, run "npm uninstall -g particle-cli"

************************************************************************
** YOU MUST CLOSE AND REOPEN YOUR TERMINAL BEFORE CHANGES TAKE EFFECT **
************************************************************************

Now it seems like there was a problem with one of the files:

KeyError: 'arm'
gunzip: (stdin): unexpected end of file

Has this something to do with the new Apple Silicon processor?
Any tips?

@FiDel

On M1 Macs you'll need to enable Rosetta in order to use particle-cli:

1 Like

Great! I’ll try this right now!
Thanks for the golden tip champion!
FiDel

@nrobinson2000 : (Maybe you will prefer to continue in the other thread?)

It was a good try, but unfortunately, after another long adventure, installing Rosetta2 and following all tips in the thread you shared, Particle CLI still does not work on this M2 Mac…
After multiple uninstalls and reinstalls, I keep getting this error:

"KeyError: 'arm'
gunzip: (stdin): unexpected end of file":

So, I reinstalled is again:

MacBook-Air:~ kampendaal$ bash <( curl -sL https://particle.io/install-cli )

PARTICLE CLI SETUP...

                                   :                                    
                                   :                                    
                                  :::                                   
                      :           :::           :                       
                       :::        :::        :::                        
                         ::::     :::     ::::                          
                          ::::::       ::::::                           
                           :::::::::::::::::                            
                             :::::::::::::                              
                    :::::::   :::::::::::   :::::::                     
                    :::::::   :::::::::::   :::::::                     
                             :::::::::::::                              
                           ::::::::.::::::::                            
                          ::::::       ::::::                           
                         ::::     :::     ::::                          
                       :::        :::        :::                        
                      :           :::           :                       
                                  :::                                   
                                   :                                    
                                                                        
:::: Installing the Particle CLI for darwin to "/Users/kampendaal/bin/particle"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
KeyError: 'arm'
gunzip: (stdin): unexpected end of file
:::: Done!
:::: Installing dependencies
:::: Done!
:::: Success!
:::: The Particle CLI has been installed to: "/Users/kampendaal/bin"
:::: Your "/Users/kampendaal/.bash_profile" file has been updated to properly set $PATH
:::: If you previously installed the CLI with npm, run "npm uninstall -g particle-cli"

************************************************************************
** YOU MUST CLOSE AND REOPEN YOUR TERMINAL BEFORE CHANGES TAKE EFFECT **
************************************************************************

When testing Particle CLI, nothing happens…

MacBook-Air:~ kampendaal$ particle login
MacBook-Air:~ kampendaal$ 

Thanks on beforehand for any more tips!

1 Like

Due to poorly made assumptions in the script and the lack of error checking, the ~/bin/particle you downloaded is an empty file, marked with executable permissions.

As a workaround, I’d recommend downloading the amd64 (Intel Mac) version of particle directly.

curl -fsLo ~/bin/particle --create-dirs \
    https://binaries.particle.io/cli/master/1.1.0-12d6799/darwin/amd64/particle

chmod +x ~/bin/particle

Afterwards you should be able to log in and install additional dependencies:

particle login
brew install dfu-util
brew install openssl
3 Likes

Wow, thanks!
I’ll try your procedure tomorrow morning…
:sleeping:

Abracadabra... It works!
I can login and list my devices!
Thanks a lot, I don't see how I could have done this without your help!!!


When I try to install the additional dependencies, it seems like it did not work:

Result:

Traceback (most recent call last):
4: from /usr/local/Library/brew.rb:32:in `<main>'
3: from /usr/local/Library/Homebrew/os/mac.rb:15:in `version'
2: from /usr/local/Library/Homebrew/os/mac.rb:15:in `new'
1: from /usr/local/Library/Homebrew/os/mac/version.rb:24:in `initialize'
/usr/local/Library/Homebrew/version.rb:170:in `initialize': Version value must be a string (TypeError)
1 Like