Particle-cli broken? "Unexpected token {" [WORKAROUND]

Hello,

I’m trying to get particle-cli running, but both on my OSX and Windows 10 machines I get the “Unexpected token {”

I’ve done all I can, reinstalled multiple times, removed my profile.json… anything else I could do? I’m trying to flash an old spark-core and I’m afraid without the CLI I cannot do much.

thanks!

UPDATE: Following instructions on this thread I replaced my settings.js and now I get:

$ particle
 !   Error in particle-cli:
 !   Cannot find module './lib/deviceSpecs'
 !   See /Users/ignacioverona/.particle/error.log for more info.
2 Likes

ok, I was not able to fix it but using the particle-cli straight from git works. It’s not really a solution, but does the job!

Is there another solution to this? I cant use GIT and i cant reformat my PC which seem to be the only 2 solutions offered. This just happened to me overnight, yesterday everything was working , today I get : “Unexpected token {” on every particle command, tried to reboot and reninstall particle CLI but no change.

Its very critical i get this working, have flown to a customer to install their robot and now I’m stuck.

1 Like

just tried the CLI on another machine that had an older version of the CLI that used to work, it said "updating CLI… " then “unexpected token {”

Tried a fresh install on a third machine that never had particle installed and it gives a different error.

1 Like

The same issue is happening to me today

1 Like

Same issue for me on macOS.

2 Likes

Same issue here. Windows 10.

1 Like

Same here, Win 10.

I even can’t compile locally using Workbench alpha7.
After deleting AppData\Local\particle, workbench reinstalled this packages, then it worked one time until trying cloud flash, then it was broken again (“Unexpected token {” on every particle command).

Current status:

  • .vscode/extensions/particle.particle-vscode-core-1.0.0-alpha.7/src/cli/bin/windows/amd64/parti
    cle.exe: “Unexpected token {”
  • particle.exe in PowerShell (reinstalled via npm): Working, but login hangs after submitting password.

Workaround to be able to compile until this gets fixed:

Same error - Ubuntu 18.04. Brand new user to particle. Making my start here a bit rough… will try direct git pull

Thanks for reporting the issue. We’ll investigate, release a fix and post here.

Using particle-cli v1.37.0 on macOS and Ubuntu without any problems. I suspect it’s something wrong with v1.38.0. Going to update to v1.38.0 on Ubuntu and see if particle-cli breaks.

Update:
Updating to v1.38.0 didn’t break particle-cli.

It’s worth noting that I’ve always installed particle-cli with:

sudo npm install -g --unsafe-perm particle-cli

Tried re-installing with --unsafe-perm flag, but it didn’t help.

npm -v // v6.7.0
node -v // v8.11.3

Particle CLI v1.38.0

I tried deleting the ~/.particle directory completely but the problem reappears after dependencies and plugins were reinstalled.

Did you try:

No dice. Just tried it and still get Unexpected token { error

hey all - apologies for the bumps here. i think the issue has been resolved. can you try running particle version and confirm you are error-free?

the problem appears to be related to the update mechanism - it doesn’t handle unexpected server responses well - otherwise v1.38.0 is ok (iow, downgrading isn’t going to help)

i’ll get it sorted :+1:

if you are a Workbench user and you’ve deleted your ~/.particle directory, you can do the following to get things back in order:

  1. launch VSCode
  2. you may be prompted to install dependencies, click “install” and wait for it to complete
  3. run the Particle: Update CLI command and wait for it to complete
  4. in the terminal panel that was launched, type particle version and confirm you are running v1.38.0

EDIT: if you’ve installed the CLI using our installers (docs), you may need to reinstall to get back up and running. the easiest way to do that is:

on windows:

  1. open a file explorer and navigate to C:\Users\<you>\AppData\Local\particle
  2. remove the following directories: .npm-cache, node_modules, node-v5.4.1-windows-x64
  3. open a powershell terminal and type particle version

on mac & linux:

  1. open a terminal
  2. go to your particle directory cd ~/.particle
  3. remove cli dependencies rm -rf ./node-v5.4.1-darwin-x64 ./.npm-cache ./node_modules (or linux as appropriate)
  4. run particle version

in both cases, you should see the “particle: Installing plugins…” message followed after some delay by 1.38.0.

1 Like

it’s now working again, thanks!

1 Like

Please turn off the auto update feature of your CLI, it has cost thousands of man hours around the world. We should be allowed to choose when to update during non critical times.
No need to copy Windows 10 up-hate methods .

I didn’t realize everyone was having this problem because of workbench.

Hey there jasperza,

As it so happens, there is a way to disable automatic updating in the CLI. You can do so by setting the environment PARTICLE_DISABLE_UPDATE=true. From there, run particle update-cli manually when you feel the need.

Minor typo in mac/linux instructions - ^windows^linux

but it’s working!

thanks

1 Like