Connecting Particle Photon to Local Server on Raspberry Pi Zero W

I am working on a project for a class where I will need two Photons to talk to each other without the time limit for publishing on the Particle Cloud. I planned on setting up a local particle-server on my Raspberry Pi Zero W so that there would not be a limit on the rate at which I can publish and subscribe to events between devices. I was able to install particle-server on my Raspberry Pi, but in order to configure the Photons to use the local cloud, I need to install particle-cli which fails to install.
This is what is read out on the terminal:

pi@raspberrypi:~ $ sudo npm install -g particle-cli
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
npm WARN excluding symbolic link test/server/static/ie8-polyfill.js -> …/…/…/ie8-polyfill.js

> spawn-sync@1.0.15 postinstall /usr/local/lib/node_modules/particle-cli/node_modules/yeoman-environment/node_modules/inquirer/node_modules/external-editor/node_modules/spawn-sync
> node postinstall

> serialport@4.0.7 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(404):
node-pre-gyp ERR! Pre-built binaries not found for serialport@4.0.7 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.9.24+
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. (/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.9.24+
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.32
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.9.24+
npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “install” “-g” "particle-cli"
npm ERR! node v4.2.1
npm ERR! npm v2.14.7

npm ERR! serialport@4.0.7 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@4.0.7 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

1 Like

This is a known but relatively undocumented bug with the particle-cli installation process. The following should work:

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

Thank You!

1 Like

Thanks for the help @nrobinson2000!

1 Like