17

Anyone on a MAC got this update to work? Anyone know how to fix?

It hangs for me on finishing up.

Now all I get when executing sfdx at the cli is:

module.js:540
    throw err;
    ^

Error: Cannot find module '/Users/xxxx/.local/share/sfdx/client/package.json'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/xxxxx/.local/share/sfdx/client/dist/versions.js:6:15)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)

Tried to reinstall, reboot, etc to no avail.

Update: After several reboots and using the download link from here I was able to get it repaired. All other links did not work.

Would be interested to know if others have issues with this update.

Update 10-18-2018 Still not working. Update hangs on finishing up Update 12-17-2018 Still not working. Update hangs on finishing up (6.44.0) Update 8-01-2019 Seems to have been resolved with latest releases

2
  • I have the exact same version and don't get this error. What os / version are you using? Commented Jun 24, 2018 at 20:22
  • I was trying to upgrade to this version of sfdx from the previous version. If hung at finishing up. On latest Mac OS. Sounds like your upgrade happened without issue then?
    – Eric
    Commented Jun 24, 2018 at 21:57

3 Answers 3

23

This happens to me every couple of days on a Mac.

A workaround is to delete the directory /Users/xxxx/.local/share/sfdx/client and then sfdx-cli will automatically upgrade on the next command your run. See Cannot find module package.json #666. This includes the comment:

as discussed in #653 this was due to a cleanup process that was too eager and deleted some essential files for some installs. A fix is out and if you're experiencing this, delete ~/.local/share/heroku/client and it should resolve itself.

PS

A colleague reports that "update Node.js to the latest (LTS) and update SFDX" stopped the problem from happening for him.

6
  • I assume this is correct since you use it. Do you think using it is the cause of your frequent errors?
    – Eric
    Commented Jul 3, 2018 at 7:21
  • @Eric For me it has fixed the problem multiple times including this morning.
    – Keith C
    Commented Jul 3, 2018 at 7:42
  • sad that this is still happening and not fixed
    – Eric
    Commented Sep 24, 2018 at 21:37
  • 1
    Oddly I didn't actually rm anything, but trying sfdx update and listing out the directories on the system that it was complaining about seemed to have triggered something and it started working again. I was going through a Trailhead course at the time and got the failure the first time I tried to deploy a scratch org. I'm wondering if the initial failed request had to time out and clean up after itself and then the next run it was OK.
    – dragon788
    Commented Nov 30, 2018 at 16:35
  • 1
    So to follow up on my above comment, I also have had to delete the recommended directory and then run sfdx update to get it working. A portion of my issues may be the fact that I'm behind a company proxy which might be blocking certain connections or triggering some race conditions when the components attempt to automatically upgrade. I've also been seeing ▸ autoupdate:: /Users/<username>/Library/Caches/sfdx/update.lock is locked with an active writer on my sfdx update and so sometimes I just delete and reinstall with brew rm sfdx && brew install sfdx to work around this.
    – dragon788
    Commented Dec 13, 2018 at 23:22
4

I got similar error on windows 10. I took a backup and deleted everything inside below folder and was able to update CLI to latest version.

C:\Users\\AppData\Local\sfdx\client

2

It just occurred to me that a longer term "fix" is to disable the SFDX auto-update mechanism by exporting the appropriate environment variable that supresses updates. That way you can run sfdx update when you want/need an update and can waste a bit of time fixing it by deleting the client directory or a reinstall if the update process doesn't work.

When you run a command, the Salesforce CLI checks to see if you have the latest version. If not, the CLI automatically updates itself and the salesforcedx plug-in. You can disable this automatic update with an environment variable. To remain on the current version of the CLI and disable automatic updates, set the SFDX_AUTOUPDATE_DISABLE environment variable to true. For example, on Unix:

export SFDX_AUTOUPDATE_DISABLE=true

Reference: https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_update_cli.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .