Tutorial: Particle-cli on Mac OSX [26 Sep 2015]


Hmmm i dont think it will be any time soon though


Hi All -

New Particle / Node user, had some of the issues above on os X 10.9.5.

Got working for me, thought Id share:

I don’t have X-Code installed on this machine.

Hope this is helpful to someone!

sudo npm uninstall npm -g
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/lib/dtrace/node.d
brew install node


For anyone who might need to wrestle with different versions of node, you can use ‘nvm’ or ‘nave’ (I use nave) to install and switch between them. You should be able to install either utility with homebrew on a Mac.


On OS X 10.10.4, you MUST install node.js version 0.10.29.

If you install node.js version 0.12.7 the install of particle-cli fails with “env: node: No such file or directory” when it tries to install serialport@1.7.4.


I have the same issue. Tried everything up to this point, but no luck :frowning:

Kerosene-IV:particle-cli Jamie$ sudo npm install -g particle-cli
> serialport@1.7.4 install /usr/local/lib/node_modules/particle-cli/node_modules/serialport
> node-pre-gyp install --fallback-to-build

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
sh: node-pre-gyp: command not found

npm ERR! serialport@1.7.4 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the serialport@1.7.4 install script.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR!     npm owner ls serialport
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 14.5.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "particle-cli"
npm ERR! cwd /usr/local/lib/node_modules/particle-cli
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! not ok code 0
Kerosene-IV:particle-cli Jamie$

As you can see from the command promt, I even created a directory called ‘particle-cli’ within /usr/ocal/bin/node_modules just in case the directory not existing was the problem… things got desperate!

Any ideas? Or is the serialport package really to blame, like the messages say?


try sudo npm install -g serialport


No dice… (same errors)


Hmm cannot help much here though this suggests it might be other issues causing the package not to install. Might want to open an issue with the serialport repo :wink:


Just tested this again from scratch and it works.


Had same problem.
Particle writes, that it wants 0.12 node version, lets do it.

  1. Install node.js
  2. Install Node Version Manager (NVM) with NVM_DIR=/usr/local/nvm option
  3. Install latest 0.x.x node version (0.12.7 in my case)
nvm install v0
  1. Install particle-cli
sudo npm install particle-cli
  1. Create usable symlink
ln -s /usr/local/lib/node_modules/particle-cli/particle.sh /usr/local/bin/particle
  1. Modify /usr/local/lib/node_modules/particle-cli/particle.sh
source /usr/local/nvm/nvm.sh
nvm run v0 /usr/local/lib/node_modules/particle-cli/app.js $*


Just a note for others that get sporadic problems with make, node-pre-gyp, or node-gyp rebuild failures with OSX, I have one more thing you can check:

I ran across this recently, and it confused me because I had just built the same packages recently with the same version of node. One day it worked, the next it didn’t. But I figured out that what changed in-between was that I had tried to install the latest XCode update. And I managed to spot something in the scrolling build messages: Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

I had to fire up XCode, and then it prompted me to agree to the new license terms. After that, my builds ran fine.


This is some kind of joke, right?

I have Mac OSX 10.10.5 running on a Mac Pro

I have Xcode 7.0 installed and have installed the additional command line tools for XCODE.

Mac-Pro:~ mjrickard$ sudo npm install -g spark-cli
npm WARN engine spark-cli@1.4.2: wanted: {"node":"^0.10.0"} (current: {"node":"4.1.0","npm":"2.14.3"})
> serialport@1.7.4 install /usr/local/lib/node_modules/spark-cli/node_modules/serialport
> node-pre-gyp install --fallback-to-build

gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/mjrickard/.node-gyp/4.1.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/spark-cli/node_modules/serialport/.node-gyp"
make: *** No rule to make target `../.node-gyp/4.1.0/include/node/common.gypi', needed by `Makefile'.  Stop.
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/usr/local/lib/node_modules/spark-cli/node_modules/serialport/build/serialport/v1.7.4/Release/node-v46-darwin-x64/serialport.node" "--module_name=serialport" "--module_path=/usr/local/lib/node_modules/spark-cli/node_modules/serialport/build/serialport/v1.7.4/Release/node-v46-darwin-x64"
gyp ERR! cwd /usr/local/lib/node_modules/spark-cli/node_modules/serialport
gyp ERR! node -v v4.1.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/spark-cli/node_modules/serialport/build/serialport/v1.7.4/Release/node-v46-darwin-x64/serialport.node --module_name=serialport --module_path=/usr/local/lib/node_modules/spark-cli/node_modules/serialport/build/serialport/v1.7.4/Release/node-v46-darwin-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/spark-cli/node_modules/serialport/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:817:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Darwin 14.5.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/spark-cli/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/spark-cli/node_modules/serialport
node-pre-gyp ERR! node -v v4.1.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.7
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/spark-cli/node_modules/serialport/build/serialport/v1.7.4/Release/node-v46-darwin-x64/serialport.node --module_name=serialport --module_path=/usr/local/lib/node_modules/spark-cli/node_modules/serialport/build/serialport/v1.7.4/Release/node-v46-darwin-x64' (1)
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "spark-cli"
npm ERR! node v4.1.0
npm ERR! npm  v2.14.3

npm ERR! serialport@1.7.4 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the serialport@1.7.4 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR!     npm owner ls serialport
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/mjrickard/npm-debug.log

No one has found a fix for this? My first official act using Electron and I can’t install the CLI? Because I use a MAC OSX???


In this case it might because you are using node 4.x. As noted in these forums, there are breaking changes in node 4.x that many modules are not up-to-date with yet. Also, if you switch from one version of node to another, I think previously installed modules can have compatibility issues (e.g., if you installed a module using node 0.10.x, then later upgraded to node 0.12.x, that module, or other modules that depend on it, could fail).

You might want to try installing nave or nvm to manage different node versions. And you might even try running npm -g rebuild after switching to node 0.12.x, which should recompile any C++ addons which might be having problems due to a node version mismatch.



my tutorial says: run the command sudo npm install -g particle-cli


Oh yeah, I didn’t even catch on that he was trying to install the old ‘spark-cli’ instead of the current ‘particle-cli’. That would be a problem, too…


Check my guide,it should help you


@kennethlimcp: Looks like Homebrew changed their install link. Updated link is now: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


Thanks @wgbartley! updated it. Use your superpower and update it next time :smile:


After experiencing many issues installing the node.js, I decided to remove everything and start fresh.

I just finished a clean install of node.js and Particle-CLI. Below are the system information and steps I took.

Hardware: MacBook Pro (15-inch Early 2008)
OS: OS X Yosemite
Version: 10.10.5 (14F27)
Xcode: Version 7.0 (7A220)
node-v0.10.29.pkg https://nodejs.org/download/release/v0.10.29/node-v0.10.29.pkg

Download & install the node from https://nodejs.org/download/release/v0.10.29/node-v0.10.29.pkg

Open a terminal window
Login as root

Type sudo ln -s /usr/local/bin/node /usr/bin/node
Wait until its done.

Type sudo npm install node-pre-gyp
Wait until its done.

Type sudo npm install -g particle-cli
Now you should see

npm WARN engine hawk@3.1.0: wanted: {“node”:">=0.10.32"} (current: {“node”:“v0.10.29”,“npm”:“1.4.14”})
npm WARN engine cryptiles@2.0.5: wanted: {“node”:">=0.10.40"} (current: {“node”:“v0.10.29”,“npm”:“1.4.14”})
npm WARN engine boom@2.9.0: wanted: {“node”:">=0.10.40"} (current: {“node”:“v0.10.29”,“npm”:“1.4.14”})
npm WARN engine hoek@2.16.3: wanted: {“node”:">=0.10.40"} (current: {“node”:“v0.10.29”,“npm”:“1.4.14”})

serialport@1.7.4 install /usr/local/lib/node_modules/particle-cli/node_modules/serialport
node-pre-gyp install --fallback-to-build

[serialport] Success: “/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/serialport/v1.7.4/Release/node-v11-darwin-x64/serialport.node” is installed via remote
/usr/local/bin/particle -> /usr/local/lib/node_modules/particle-cli/bin/particle.js
particle-cli@1.8.3 /usr/local/lib/node_modules/particle-cli
├── fast-luhn@1.0.2
├── cli-spinner@0.2.1
├── xtend@4.0.0
├── chalk@1.1.1 (escape-string-regexp@1.0.3, supports-color@2.0.0, ansi-styles@2.1.0, has-ansi@2.0.0, strip-ansi@3.0.0)
├── when@3.7.3
├── cli-table@0.3.1 (colors@1.0.3)
├── node-wifiscanner2@1.1.0 (os-locale@1.4.0)
├── glob@4.5.3 (inherits@2.0.1, once@1.3.2, inflight@1.0.4, minimatch@2.0.10)
├── hogan.js@2.0.0
├── request@2.64.0 (aws-sign2@0.5.0, forever-agent@0.6.1, caseless@0.11.0, stringstream@0.0.4, tunnel-agent@0.4.1, oauth-sign@0.8.0, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.0, node-uuid@1.4.3, combined-stream@1.0.5, qs@5.1.0, form-data@1.0.0-rc3, mime-types@2.1.7, http-signature@0.11.0, bl@1.0.0, tough-cookie@2.0.0, hawk@3.1.0, har-validator@1.8.0)
├── lodash@3.10.1
├── moment@2.10.6
├── softap-setup@1.1.4 (nconf@0.7.2, node-rsa@0.2.25)
├── inquirer@0.8.5 (ansi-regex@1.1.1, figures@1.4.0, cli-width@1.0.1, through@2.3.8, readline2@0.1.1, rx@2.5.3)
└── serialport@1.7.4 (bindings@1.2.1, sf@0.1.7, async@0.9.0, nan@1.8.4, debug@2.2.0, optimist@0.6.1)

Type particle login
? Please enter your email address: *******@**.
? Please enter your password: ******

Successfully completed login!

Spark Particle CLI installation help

I got the same node-pre-gyp errors (when installing serialport) and found that the fix was changing versions. This was a bit tricky. Uninstalling everything, installing nvm, running nvm install 0.10, restarting the shell, and then sudo npm install serialport worked.