Just updated to particle cli in the normal way (I think it was v2.0.0). Problem is that I now cannot run any commands, eg "particle", from the command line!
All attempts return the following:
$ particle
/usr/local/lib/node_modules/particle-cli/dist/app/cli.js:144
async runCommand(args) {
^^^^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/usr/local/lib/node_modules/particle-cli/dist/index.js:8:13)
if you prefer the “advanced” path where you manage the node runtime yourself, read on.
the node ecosystem adheres (more or less) to SemVer (https://semver.org/). Amongst other rules, SemVer specifies that you should bump the major version number when introducing breaking changes. in this case, our move to particle-cli@2.0.0 signals just such a breaking-change - which is simply that we no longer support node@6.
in general, we aim to support the current node LTS (long-term support) lines:
…which at the time of this posting is v12, v10, and v8.
v6 LTS ended back in april (4/30/2019 specifically) - as shown here - which is why we dropped it.
I am having issues with particle-cli that I believe may be related to version.
node - v10.15.3
npm - v6.10.1
I am running Mac Catalina and have tried both BASH and zsh no difference in the error message when I run the “particle identify” command with a device in listening mode on my USB port:
! The `serialport` dependency is missing or invalid.
! Please reinstall: https://docs.particle.io/tutorials/developer-tools/cli/#installing
There was no .node-* directories under ~/.particle - Node is somewhere else?
are you on Windows? if not, then i'm guessing you used the "Advanced" install method
(docs) when you originally installed the CLI.
unless you are comfortable using node.js, i would recommend the standard install path. unfortunately, moving from one to the other requires some work to uninstall the global node.js runtime and the particle-cli package. to start, you'd run npm uninstall -g particle-cli.
I always have to type sudo before particle update-cli or it does not work.
this speaks to having previously installed using the "Advanced" instructions - you shouldn't need to use sudo when installing packages. that you do, speaks to some misconfiguration of your local node.js environment.
Do I have a “global” node issue?
sounds like it.
how do I fix it?
there are all sorts of guides out there with instructions on how to install and configure node.js - here's one that seems good:
if you are on a mac, i personally recommend using Homebrew to install and manage node.js:
Uninstalled node using the first article and - as the article suggested - reinstalled via NVM
as i said earlier, if you aren't comfortable managing a local node.js installation, i would stick to the standard Particle CLI install path (docs). iow, completely remove the global node.js install and install the CLI using those instructions.
I am assuming that putting sudo back in would likely fix it but, I would prefer not to. Any advice?
just what i've shared here already and to be 100% certain your permissions are set appropriately:
OK, sorry, I misunderstood your instructions - my fault.
I have completely uninstalled node and then used the instructions from the doc (Mac Catalina). I am getting the same errors but, let me focus on one line as this might point to the cause.
I looked at my permissions for the ~/.particle directory and see this:
drwxr-xr-x 9 chipmc staff 288B Jan 10 16:47 .
drwxr-xr-x+ 44 chipmc staff 1.4K Jan 10 16:46 ..
drwxr-xr-x 6 chipmc staff 192B Jan 10 14:52 .npm-cache
-rw-r--r-- 1 chipmc staff 54B Jan 10 14:36 autoupdate
-rw-r--r-- 1 chipmc staff 330K Jan 10 16:47 error.log
drwxr-xr-x 9 chipmc staff 288B Mar 8 2019 node-v8.15.0-darwin-x64
drwxr-xr-x 438 chipmc staff 14K Jan 8 11:13 node_modules
-rw-r--r-- 1 chipmc staff 145B Jan 9 12:56 particle.config.json
drwxr-xr-x 7 chipmc staff 224B Dec 7 15:01 toolchains
Let’s focus on the node_modules line which - to my eye says I have owner permissions to read, write and execute to this directory. However, in the terminal, I see this error:
cmcclell-OSX:~ chipmc$ bash <( curl -sL https://particle.io/install-cli )
Installing the Particle CLI to /Users/chipmc/bin/particle
particle: Installing plugins...
â–¸ npm WARN checkPermissions Missing write access to /Users/chipmc/.particle/node_modules/particle-cli/node_modules/@babel/core/node_modules/@babel/parser
which particle # should point to ~/.particle/bin
particle version # should return v2.0.1 (as of today)
particle usb list # should NOT return an error about missing dependencies
particle serial inspect # ditto - no error about missing dependencies
if the CLI is still not working, i’m honestly stumped.
Turns out that on my system two of the targets you show as hidden were not.
Here are the steps I was following:
delete the following files and directories if available:
.npm-cache
autoupdate
error.log
./node-v8.15.0-<os>-<cpu>
(e.g. node-v8.15.0-windows-x64, node-v8.15.0-darwin-x64, node-v8.15.0-linux-x64)
./node_modules
but, on my system the ./node-v8.15.0 … and the ./node_modules were not hidden and, if I omitted the “.”, I was able to delete them and then the particle update-cli command worked perfectly.
So, to summarize:
Followed your advice and deleted the “global” node from my system