Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR running force:source:retrieve: Cannot read property 'getInstance' of undefined #564

Closed
quygiengtmobile opened this issue Aug 13, 2020 · 9 comments

Comments

@quygiengtmobile
Copy link

Summary

received Error:
ERROR running force:source:retrieve: Cannot read property 'getInstance' of undefined

on all sfdx cmd: example: sfdx force:source:retrieve

Steps To Reproduce:

  1. This is step 1. sfdx force:source:retrieve
    and received an error.

Expected result

expected no error

Actual result

ERROR running force:source:retrieve: Cannot read property 'getInstance' of undefined

Additional information

Feel free to attach a screenshot.

VS Code Version: 1.47.3

SFDX CLI Version: 49.4.0

OS and version: MacOS 10.15.6

@chriswill
Copy link

I am also seeing this error. I've been pulling my hair out trying to resolve. I've reinstalled the CLI components several times and have started with a clean .sfdx directory. Currently am completely blocked on development.

My scenario:

PS C:\git\repos\salesforce-adapter> sfdx force:auth:web:login -d -a [myHub]
ERROR running force:auth:web:login:  Cannot read property 'getInstance' of undefined

The log files show:

{"name":"sfdx","hostname":"GAINE-DEV16","pid":21772,"log":"SfdxProjectJson","level":40,"msg":"The config file: C:\\Users\\Chris Williams\\.sfdx\\sfdx-project.json is not schema valid\nDue to: Validation errors:\nshould have required property 'packageDirectories'","time":"2020-08-13T17:20:12.781Z","v":0}
{"name":"sfdx","hostname":"GAINE-DEV16","pid":21772,"log":"SfdxProjectJson","level":40,"msg":"The config file: C:\\Users\\Chris Williams\\.sfdx\\sfdx-project.json is not schema valid\nDue to: Validation errors:\nshould have required property 'packageDirectories'","time":"2020-08-13T17:20:12.791Z","v":0}
{"name":"sfdx","hostname":"GAINE-DEV16","pid":21772,"log":"AuthWebLoginCommand","level":50,"msg":"[\n  '\\u001b[1mERROR running force:auth:web:login: \\u001b[22m',\n  \"\\u001b[31mCannot read property 'getInstance' of undefined\\u001b[39m\"\n]","time":"2020-08-13T17:20:12.806Z","v":0}

I do not have a sfdx-project.json file in my .sfdx directory.

The only file in .sfdx is sfdx.log.

I do have a sfdx-project.json file in my current project directory. It has the correct packageDirectories content.

Additional information

VS Code Version: 1.47.3

SFDX CLI Version: sfdx-cli/7.69.0-c7be45ae22

OS and version: Windows 10, version 1909

@dhaniksahni
Copy link

dhaniksahni commented Aug 14, 2020

Facing same issue while pushing any lwc component to org.

@lcampos lcampos transferred this issue from forcedotcom/salesforcedx-vscode Aug 14, 2020
@lcampos
Copy link

lcampos commented Aug 14, 2020

@chriswill @dhaniksahni @quygiengtmobile I'm wondering if this is a new issue or a previously existing one, have you tried downgrading to a previous CLI version ?

@amphro
Copy link
Contributor

amphro commented Aug 14, 2020

This is due to having unnecessary plugins installed. We still aren't sure why the node_module resolution is getting messed up because the getInstance is there until it goes into the overwritten plugin code.

You should be able to do sfdx plugins to see what you have installed and do sfdx plugins:uninstall salesforcedx or whatever the offending plugins is.

See #555 for more details.

Notice in the thread you should not reinstall those plugins unless targeting old plugin versions.

@ghost
Copy link

ghost commented Aug 14, 2020

Thank you! I've been searching for a solution for this for several days now.

Just some background to assist others: I'm not sure what triggered the Cannot read property 'getInstance' of undefined error initially, but one day it was working, the next day it wasn't. I did not upgrade the CLI, it has been running version 7.69.0-c7be45ae22 for several weeks now. I checked for an update today, which updated it to sfdx-cli/7.70.1-3d8a6229fc. The update didn't help, but after finding this post I did the following to resolve the issue:
sfdx plugins:uninstall salesforcedx

@amphro Are you saying there is no need to reinstall the salesforcedx plugin? Are they part of the sfdx core package now?

@quygiengtmobile
Copy link
Author

Hi All,
I fixed this issue by clear all cli cache and data then install again.

@chriswill
Copy link

I fixed this issue by following steps in #555

sfdx plugins:uninstall salesforcedx

@aman993
Copy link

aman993 commented Aug 14, 2020

Make sure your .sfdx folder has a sfdx-config.json file. If it is present try removing it and adding it again and authorize an org. the file should contain a json structure as follows:
{
"defaultusername": "org alias name"
}
Authorize an org again and you should be good.

I tried the same and it redirected me to salesforce log in page and now the error does not come anymore.

@amphro
Copy link
Contributor

amphro commented Sep 10, 2020

| @amphro Are you saying there is no need to reinstall the salesforcedx plugin? Are they part of the sfdx core package now?

Correct. They have been bundled with the CLI since the beginning. You only need to install it if you want to hardcode to a specific version.

Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants