CLI concepts and operation

I have a big conceptual problem with your CLI. I have two Photons and have set them up, written programs for them and am using them to measure temperature and humidities, publishing these values to the web. I successfully use the Particle build environment to compile and flash programs. I have a web server set up on a VPS that allows me to query the Photons. So I can do lots of things I want with them.

But in exploring the documentation I came across the CLI section and I want to use it an alternative to Build. But I am stumped about where it runs, how or if it connects to the Photon and what it does.

It is not actually explicitly mentioned but it looks like it runs as a nodejs program on a user’s PC or MAC running Linux, Windows or the OSX, and communicates with the particle cloud via the internet and the user’s Photon devices via a usb serial port. It seems to provide functions for flashing devices, installing webhooks, listing devices, etc. I want to do these using the CLI as an alternative to Build.

Now I don’t have a PC or MAC available and have been doing all my work on a chromebook and virtual private servers (VPS) running Linux. I thought I’d try using the CLI commands that don’t involve connecting directly to the Photon (which is never mentioned directly but assumed by statements like ‘make sure your device is connected’.) So I tried installing the CLI on my VPS and it failed:

henry@ocean1:~$ sudo  npm install -g particle-cli
npm http 200
npm http 200
> serialport@2.0.5 install /usr/local/lib/node_modules/particle-cli/node_modules/serialport
    > node-pre-gyp install --fallback-to-build
    /usr/bin/env: node: No such file or directory
    npm WARN This failure might be due to the use of legacy binary "node"
    npm WARN For further explanations, please read
    npm ERR! weird error 127
    npm ERR! not ok code 0

Before I spend time debugging the install I thought I’d ask the more fundamental question: Can I run it from a Ubuntu 14.04 VPS and do things that don’t involve direct connection to a Photon?

What version of node are you running? From the error I suspect you might have iojs. Node 4 or greater should work great.

And to be clear you can query the node version with node -v

henry@ocean1:~$ nodejs -v

Wait, what? I use the javascript runtime nodejs. What is node?

Other info:

/etc/os-release:PRETTY_NAME="Ubuntu 14.04.1 LTS"

nodejs vs node from /usr/share/doc/nodejs/README.Debian:

nodejs command

The upstream name for the Node.js interpreter command is "node".
In Debian the interpreter command has been changed to "nodejs".

This was done to prevent a namespace collision: other commands use
the same name in their upstreams, such as ax25-node from the "node"

Scripts calling Node.js as a shell command must be changed to instead
use the "nodejs" command.

Its the same thing, you can install nodejs-legacy (which is really just a symlink) if you want to be able to use just “node”