Particle CLI on Raspberry Pi?

So I’m working on a project that will include a few Photons connecting to a Raspberry Pi B+/A+. So I can connect to the Photon through my PC’s Particle CLI, but I tried installing it onto my Raspberry Pi (using several techniques such as: the firections for installing the Particle CLI for Linux on the Particle documentation and following this tutorial.

I’ve successfully installed Node.js and npm and still am unable to get it to install properly because I always get errors like this:

Attempted Solutions: Different SD Card, Reformatted OS, Installed Node several different ways.

If anyone could provide a solution or an alternate, I would really appreciate it!

You're not really giving much info, but did you notice this?

Confused though - you say you successfully installed Node.js and npn but then say you're unable to get it to install properly??

Perhaps some more info and better/clearer screenshots so we know what you're really doing.

@rsaiyid it is a little unclear what problem you’re encountering. However, I have vague recollection that the newer current raspberry pi kernel throws some new permissions hurdles, but somehow I was able to get particle-cli on the new kernel. So look through the error messages you receive for anything that says something like "does not have permission to write to " some directory, and then make a reasonable decision about changing that directory’s permission level if it seems safe to you to do so. Sorry I don’t have a clearer recollection. I did check my installation and see that serialport@2.0.6 does install on the pi. I’d suggest you first just fiddle around trying to just install serialport@2.0.6. Come to think of it, I think I needed to first install node-gyp separately (sudo npm install -g node-gyp , then later, sudo npm install -g serialport@2.0.6)
Hope that helps and sorry I don’e recall the exact steps.

Hey just wanted to update, I tried going through again and using serialport@2.0.6 and installing node -gyp before it. Unfortunately even that doesn’t seem to work.

I just noticed a permission error:

user "root" does not have permission to access the dev dir "/root/.node-gyp/0.12.6"

Also:

/usr/local/lib/node_modules/serialport
node -v > v0.12.6
node-gyp -v > v2.0.1
not ok

If you remember anything or know of a way to help me fix this error I’d greatly appreciate it.

@rsaiyid Possibly it’s the node version. I have node 4.2.1 installed on the pi 3. If you still have permission problems try using chmod; there’s lots of raspberry pi tutorials on how to use chmod.

@rsaiyid Did you get particle-cli installed on rpi?
These steps worked without a hitch on a fresh install of raspian jessie on a RPI 3

pi@raspberrypi:~ $ sudo apt-get update && sudo apt-get upgrade

pi@raspberrypi:~ $ sudo apt-get remove --purge node nodejs

pi@raspberrypi:~ $ sudo apt-get autoremove

pi@raspberrypi:~ $ wget http://node-arm.herokuapp.com/node_latest_armhf.deb

pi@raspberrypi:~ $ sudo dpkg -i node_latest_armhf.deb

pi@raspberrypi:~ $ node -v

pi@raspberrypi:~ $ npm -v

pi@raspberrypi:~ $ git clone https://github.com/spark/particle-cli particle-cli

pi@raspberrypi:~ $ cd particle-cli

pi@raspberrypi:~/particle-cli $ sudo npm install -g serialport@2.0.1 particle-cli
4 Likes

WOW!
Thanks so much it finally worked!

I tried your instructions but I got even more errors than the other tutorials and it still didn’t work.
The error codes:

pi@raspberrypi:~ $ sudo npm install -g serialport@2.0.1 particle-cli
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
/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@2.0.1 install /usr/local/lib/node_modules/serialportnnn
> node-pre-gyp install --fallback-to-build

(node) child_process: options.customFds option is deprecated. Use options.stdio instead.
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/4.2.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/serialport/.node-gyp"
make: Entering directory '/usr/local/lib/node_modules/serialport/build'
  CXX(target) Release/obj.target/serialport/src/serialport.o
  CXX(target) Release/obj.target/serialport/src/serialport_unix.o
  CXX(target) Release/obj.target/serialport/src/serialport_poller.o
  SOLINK_MODULE(target) Release/obj.target/serialport.node
  COPY Release/serialport.node
  COPY /usr/local/lib/node_modules/serialport/build/serialport/v2.0.1/Release/node-v46-linux-arm/serialport.node
  TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory '/usr/local/lib/node_modules/serialport/build'

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

node-pre-gyp ERR! Tried to download: https://github.com/voodootikigod/node-serialport/releases/download/3.1.2/serialport-v3.1.2-node-v46-linux-arm.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for serialport@3.1.2 and node@4.2.1 (node-v46 ABI) (falling back to source compile with node-gyp) 
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/4.2.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/particle-cli/node_modules/serialport/.node-gyp"
make: Entering directory '/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build'
make: *** No rule to make target '../.node-gyp/4.2.1/include/node/common.gypi', needed by 'Makefile'.  Stop.
make: Leaving directory '/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build'
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 Linux 4.4.13-v7+
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/particle-cli/node_modules/serialport/build/Release/serialport.node" "--module_name=serialport" "--module_path=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release"
gyp ERR! cwd /usr/local/lib/node_modules/particle-cli/node_modules/serialport
gyp ERR! node -v v4.2.1
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/particle-cli/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/particle-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:818:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Linux 4.4.13-v7+
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/particle-cli/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/particle-cli/node_modules/serialport
node-pre-gyp ERR! node -v v4.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.28
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/particle-cli/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release' (1)
npm ERR! Linux 4.4.13-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "serialport@2.0.1" "particle-cli"
npm ERR! node v4.2.1
npm ERR! npm  v2.14.7
npm ERR! code ELIFECYCLE

npm ERR! serialport@3.1.2 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the serialport@3.1.2 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!     /home/pi/npm-debug.log
pi@raspberrypi:~ $ 

Any suggestions?

@Ben_is_best
It took some experimenting but I discovered the steps below work. There must have been some changes in the raspberry pi firmware or or relevant node modules or something.

pi@raspberrypi:~ $ sudo apt-get update && sudo apt-get upgrade

pi@raspberrypi:~ $ sudo apt-get remove --purge node nodejs

pi@raspberrypi:~ $ sudo apt-get autoremove

pi@raspberrypi:~ $ wget http://node-arm.herokuapp.com/node_latest_armhf.deb

pi@raspberrypi:~ $ sudo dpkg -i node_latest_armhf.deb

pi@raspberrypi:~ $ node -v

pi@raspberrypi:~ $ npm -v

pi@raspberrypi:~ $ sudo npm install -g node-gyp

pi@raspberrypi:~ $ sudo npm install -g node-pre-gyp

pi@raspberrypi:~ $ sudo npm install -g serialport@2.0.1

pi@raspberrypi:~ $ git clone https://github.com/spark/particle-cli particle-cli

pi@raspberrypi:~ $ cd particle-cli

{now make sure you are in the particle-cli folder and then delete the node_modules subfolder in particle-cli folder if it exists there }

{now open the package.json file in the particle-cli folder and change the line that reads “serialport”: “^2.0.1”, to read “serialport”: “2.0.1”, in other words remove the ^}

pi@raspberrypi:~/particle-cli $ sudo npm install -g
{don’t include the serialport@2.0.1 particle-cli part unlike the earlier instructions}

Let me know if it works for you.

1 Like

That worked! Thank you.

I discovered @mumblepins node install method: https://github.com/mumblepins/bluz-gateway and was able to install node 7 easily on an RPI3 and then afterwards particle-cli just as easily using npm install -g particle-cli
Thanks @mumblepins !
But I think it’s necessary to first run sudo apt-get remove --purge node nodejs beforehand if you have an earlier version

I installed node 7.4.0 but ran into permission errors witNPM install so used sudo to run the install and was greeted with fewer errors but found I didn’t have permission to write to node-gyp folder. It turns out that ‘sudo npm’ automatically sets --unsafe-perm to false making the location unwriteable… result: fail. So I ran `sudo npm install -g partical-cli --unsafe-perm --build-from-source" and got a working Serial and Particle-cli install with no errors.

3 Likes

@pwillard
Thanks for discovering and sharing this! Seems to be the only way to get the latest particle-cli on rpi

1 Like

yeah, particle-cli has a dependency on the Serial module, and there is no pre-compiled binary for Serial for the Raspberry Pi. Hence node-gyp tries to automatically build from source, and unsafe-perms flag raises it’s ugly head. It is actually documented as in the install guide for Serial (don’t ask me how I know!) … which of course everyone reads when installing particle-cli, don’t they? :open_mouth: :laughing: