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


#1

1.) Install node.js from http://nodejs.org/download/ [Version 0.10.x would be good]

2.) Once that is completed, launch your “terminal”

run the command sudo npm install -g particle-cli

3.) Once the installation is completed, you test that everything works by typing:

particle login


DFU-UTIL

This is optional and added here in case you could not follow the github steps (https://github.com/spark/core-firmware#3-device-firmware-upgrade-utilities).

1.) Launch a Terminal and run this code:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2.) Once homebrew is installed, we will install DFU-util

brew install dfu-util

Sorry for the weird screenshot since i have it installed already. But you should probably get the idea :wink:

That’s all!

Kennethlimcp :slight_smile:


[Howto] Setup photon if docs step fail
New CLI on OS X 10.11 El Capitan [SOLVED]
Spark Gets Local IP, Won't Connect
How can I build apps locally like I do on the WEB IDE?
Solid Purple LED
No cores found!
Npm install particle-cli not working on mac os x el capitan
Photon Challenge (Breathing Green)
Photon Setup Failed at "Verify Product Ownership"
#2

Nice! Thanks for posting! :slight_smile:


#3

maybe make a pull request to https://github.com/spark/spark-cli ?

its pretty much the same on all platforms though. on debian i think i had to symlink “node” to “nodejs” as one of the spark dependencies expected a binary called “node”.

su -
apt-get install node npm
ln -s /usr/bin/nodejs /usr/bin/node
npm install -g spark-cli

#4

Hi
Installing node.js on MacOS 10.9 doesn’t seem to have installed all that I need, or at least in the expected places:
(and, /usr/local/bin is in my PATH)

$ sudo node npm install -g spark-cli

module.js:340
throw err;
^
Error: Cannot find module '/Users/raymond/Downloads/npm’
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)


#5

and this failed in it’s own way
sudo node /usr/local/bin/npm install -g spark-cli

> serialport@1.4.0 install /usr/local/lib/node_modules/spark-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


#6

Thanks for letting me know! I will check in few hours time :slight_smile:

Node.js isn’t the issue I think. It’s just an application. It’s some installation required that gone south.

Im guessing the serialport module might be funky.

Do you have the full error code for node npm install -g spark-cli ?


#7

Hi @raygeeknyc,

I think that command should just be:

npm install -g spark-cli

Thanks!
David


#8

Is that so? I need to update my notes then!

Post updated! @raygeeknyc sorry for the blunder :wink:


#9

Still not working

$ sudo npm install -g spark-cli

serialport@1.4.0 install /usr/local/lib/node_modules/spark-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.4.0 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the serialport@1.4.0 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 13.2.0
npm ERR! command “node” “/usr/local/bin/npm” “install” “-g” "spark-cli"
npm ERR! cwd /Users/raymond/Downloads/windoze
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/raymond/Downloads/windoze/npm-debug.log
npm ERR! not ok code 0


#10

OH yes! as wild as my guesses went (i looked at your error :p) the serialport module is causing an issue.

Let me check and get back to you in a bit :wink:

@raygeeknyc, can you try sudo npm install -g serialport

It should work… I’m like 10.9.3 Mac OSx

I think i might have found the problem… Can you tell me which version of Node.js are you on?


#11

Node.js is v0.10.29

installing serialport failed

$ sudo npm install -g serialport
/usr/local/bin/serialportlist -> /usr/local/lib/node_modules/serialport/bin/serialportList.js
/usr/local/bin/serialportterm -> /usr/local/lib/node_modules/serialport/bin/serialportTerminal.js
serialport@1.4.0 install /usr/local/lib/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.4.0 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the serialport@1.4.0 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 13.2.0
npm ERR! command “node” “/usr/local/bin/npm” “install” “-g” "serialport"
npm ERR! cwd /Users/raymond/Downloads/windoze
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/raymond/Downloads/windoze/npm-debug.log
npm ERR! not ok code 0


#12

Ok can you run sudo npm install node-pre-gyp ? :slight_smile:

@raygeeknyc, can you also change your dir to elsewhere instead of /usr/local/bin ?


#13

Done.

$ sudo npm install node-pre-gyp
node-pre-gyp@0.5.19 node_modules/node-pre-gyp
$

The same error when installing serialport but then I did some research and tried this fix

sudo ln -s /usr/local/bin/node /usr/bin/node

and then serialport and spark-cli installed fine


#14

Cool! Glad you got it working. Have fun! :slight_smile:


#15

Thanks - once the CLI was installed, everything else worked like a charm. I am on a Wifi network that does not permit point-to-point connections within the local network and due to this the wireless setup for my Core was unable to complete. I set the network via USB and all is well!


#16

I’m getting the same error on the serialport portion of the install. I tried making the symlink, but it didn’t seem to help. Can you explain a little more what that link is actually doing? Running the sudo npm install node-pre-gyp worked fine, but didn’t fix the serialport errors.

Error message below:

$ sudo npm install -g spark-cli
         
> serialport@1.4.0 install /usr/local/lib/node_modules/spark-cli/node_modules/serialport
> node-pre-gyp install --fallback-to-build
        
child_process: customFds option is deprecated, use stdio instead.
gyp ERR! configure error|
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
gyp ERR! stack     at install (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:66:16)
gyp ERR! stack     at Object.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:66:37)
gyp ERR! stack     at getNodeDir (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:152:20)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:95:9
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:722:7)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at maybeClose (child_process.js:999:16)
gyp ERR! stack     at Socket.<anonymous> (child_process.js:1167:11)
gyp ERR! stack     at Socket.emit (events.js:107:17)
gyp ERR! stack     at Pipe.close (net.js:461:12)
gyp ERR! System Darwin 13.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--name=serialport" "--configuration=Release" "--module_name=serialport" "--version=1.4.0" "--major=1" "--minor=4" "--runtime=node" "--node_abi=node-v14" "--platform=darwin" "--target_platform=darwin" "--arch=x64" "--target_arch=x64" "--module_main=./serialport" "--host=https://node-serialport.s3.amazonaws.com/" "--module_path=/usr/local/lib/node_modules/spark-cli/node_modules/serialport/build/serialport/v1.4.0/Release/node-v14-darwin-x64" "--remote_path=./serialport/v1.4.0/Release/" "--package_name=node-v14-darwin-x64.tar.gz" "--staged_tarball=build/stage/serialport/v1.4.0/Release/node-v14-darwin-x64.tar.gz" "--hosted_path=https://node-serialport.s3.amazonaws.com/serialport/v1.4.0/Release/" "--hosted_tarball=https://node-serialport.s3.amazonaws.com/serialport/v1.4.0/Release/node-v14-darwin-x64.tar.gz"
gyp ERR! cwd /usr/local/lib/node_modules/spark-cli/node_modules/serialport
gyp ERR! node -v v0.11.14-pre
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok 
node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node rebuild --name=serialport --configuration=Release --module_name=serialport --version=1.4.0 --major=1 --minor=4 --runtime=node --node_abi=node-v14 --platform=darwin --target_platform=darwin --arch=x64 --target_arch=x64 --module_main=./serialport --host=https://node-serialport.s3.amazonaws.com/ --module_path=/usr/local/lib/node_modules/spark-cli/node_modules/serialport/build/serialport/v1.4.0/Release/node-v14-darwin-x64 --remote_path=./serialport/v1.4.0/Release/ --package_name=node-v14-darwin-x64.tar.gz --staged_tarball=build/stage/serialport/v1.4.0/Release/node-v14-darwin-x64.tar.gz --hosted_path=https://node-serialport.s3.amazonaws.com/serialport/v1.4.0/Release/ --hosted_tarball=https://node-serialport.s3.amazonaws.com/serialport/v1.4.0/Release/node-v14-darwin-x64.tar.gz' (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:76:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
node-pre-gyp ERR! stack     at maybeClose (child_process.js:999:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1071:5)
node-pre-gyp ERR! System Darwin 13.2.0
node-pre-gyp ERR! command "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 v0.11.14-pre
node-pre-gyp ERR! node-pre-gyp -v v0.5.19
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node rebuild --name=serialport --configuration=Release --module_name=serialport --version=1.4.0 --major=1 --minor=4 --runtime=node --node_abi=node-v14 --platform=darwin --target_platform=darwin --arch=x64 --target_arch=x64 --module_main=./serialport --host=https://node-serialport.s3.amazonaws.com/ --module_path=/usr/local/lib/node_modules/spark-cli/node_modules/seth=./serialport/v1.4.0/Release/ --package_name=node-v14-darwin-x64.tar.gz --staged_tarball=build/stage/serialport/v1.4.0/Release/node-v14-darwin-x64.tar.gz --hosted_path=https://node-serialport.s3.amazonaws.com/serialport/v1.4.0/Release/ --hosted_tarball=https://node-serialport.s3.amazonaws.com/serialport/v1.4.0/Release/node-v14-darwin-x64.tar.gz' (1)
npm ERR! serialport@1.4.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the serialport@1.4.0 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 13.2.0
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "spark-cli"
npm ERR! cwd /usr/bin
npm ERR! node -v v0.11.14-pre
npm ERR! npm -v 1.4.14
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /usr/bin/npm-debug.log
npm ERR! not ok code 0

#17

I’m not sure why you guys are getting those error…

Can you do this:

cd
sudo npm install spark-cli

#18

Same failure on serial port. Full log: https://pastee.org/dnd24


#19

@pickledgator, if you wish, add me on google chat (kennethlimcp[at]gmail.com) and we can sort if out offline :wink:


#20

@kennethlimcp @pickledgator Did you guys figure out this issue? I’m having the same problems. The symlink didn’t fix the error.