Error in particle cli: Cannot find module 'core-js/modules/es.array.index-of' [SOLVED]

photon
Tags: #<Tag:0x00007fe21a6446b0>

#1

I’ve been working with my Particle Photon but for some reason today I’ve been unable to run any particle command.

And after trying to flash my Particle Photon, I saw this output from CLI in Windows 10:

 !   Error in particle-cli:
 !   Cannot find module 'core-js/modules/es.array.index-of'
 !   See C:\Users\general_user\AppData\Local\particle\error.log for more info.

Look for the error.log file and this was the output:

2019/08/29 14:56:19 Time since last update 6h9m34.1629292s, update in block
2019/08/29 14:56:24 Time since last update 6h9m39.2707021s, update in background
2019/08/29 14:56:24 Time since last update 6h9m39.2956778s, update in block
2019/08/29 14:56:24 Time since last update 6h9m39.2996752s, update in background
2019/08/29 14:56:25 Manifest version 1.0.1-e04264e, Installed version 1.0.1-e04264e
2019/08/29 14:56:25 Updating CLI... 
2019/08/29 15:10:37 Time since last update 14m12.8793967s, update in block
2019/08/29 20:10:38 module.js:550
    throw err;
    ^

Error: Cannot find module 'core-js/modules/es.array.index-of'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\AIOTIK-005\AppData\Local\particle\node_modules\particle-cli\dist\app\cli.js:3:1)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
2019/08/29 15:10:38 Time since last update 14m13.269158s, update in background
2019/08/29 15:13:13 Time since last update 16m48.7796612s, update in block
2019/08/29 20:13:13 module.js:550
    throw err;
    ^

Error: Cannot find module 'core-js/modules/es.array.index-of'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\AIOTIK-005\AppData\Local\particle\node_modules\particle-cli\dist\app\cli.js:3:1)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
2019/08/29 15:13:13 Time since last update 16m49.0784808s, update in background
2019/08/29 15:30:28 Time since last update 34m3.5628801s, update in block

And looking for a solution here on the community I tried with this commands:

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

but getting the same results setting them as administrator or without being administrator and this was the last messages from cli after execute sudo npm install -g --unsafe-perm particle-cli

> node postinstall

npm WARN rollback Rolling back node-pre-gyp@0.12.0 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\general_user\AppData\Roaming\npm\node_modules\particle-cli\node_modules\fsevents\node_modules'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\particle-cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ particle-cli@1.44.0
added 1239 packages from 1324 contributors in 49.533s

C:\WINDOWS\system32>particle setup
 !   Error in particle-cli:
 !   Cannot find module 'core-js/modules/es.array.index-of'
 !   See C:\Users\general_user\AppData\Local\particle\error.log for more info.

What should I do? Should I reinstall the particle CLI? Thanks!


#2

I basically reinstalled with the Particle CLI Installer and the problem was solved.


#3

On Windows you should not use npm to install/update/uninstall CLI.

  • To install you’d use the Installer (as you have done).
  • To update you should use particle update-cli.
  • To uninstall you’d use Windows’ own Add/remove program feature.

Also don’t run CLI from a system directory like C:\WINDOWS\System32.
Always move to a user writable folder otherwise some commands will fail due to lack of privileges (even if you are on a Administrator account).

BTW, AFAICT Windows command line would not support sudo, so not sure what you tried but I doubt it was


#4

You are right.

What I typed in the CLI was:

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

instead of:

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

Since on Windows 10 there’s no sudo commands available.