You need to sign in to do that
Don't have an account?
Unable to run any CLI commands for my SFDX projects except for creating a project
I am getting an error when I run CLI commands after creating a project: Cannot read property 'getInstance' of undefined
I am suddenly unable to do any CLI commands with both existing and new projects. The only thing I can do is create the initial project. Everything else gives me this error.
Here's the error in the console:
console.ts:137 [Extension Host] {
"status": 1,
"name": "TypeError",
"message": "Cannot read property 'getInstance' of undefined",
"exitCode": 1,
"commandName": "ConfigGetCommand",
"stack": "TypeError: Cannot read property 'getInstance' of undefined\n at ConfigGetCommand.hooksFromLifecycleEvent (/Users/alaricwimer/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@salesforce/command/lib/sfdxCommand.js:401:44)\n at ConfigGetCommand.init (/Users/alaricwimer/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@salesforce/command/lib/sfdxCommand.js:248:20)\n at async ConfigGetCommand._run (/Users/alaricwimer/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@salesforce/command/lib/sfdxCommand.js:92:13)\n at async Config.runCommand (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/node_modules/@oclif/config/lib/config.js:172:9)\n at async Main.run (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/node_modules/@oclif/command/lib/main.js:22:9)\n at async Main._run (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/node_modules/@oclif/command/lib/command.js:43:20)\n at async Object.run (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/dist/cli.js:32:20)\nOuter stack:\n at Function.wrap (/Users/alaricwimer/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@salesforce/core/lib/sfdxError.js:151:27)\n at ConfigGetCommand.catch (/Users/alaricwimer/.local/share/sfdx/node_modules/salesforce-alm/dist/ToolbeltCommand.js:247:46)\n at async ConfigGetCommand._run (/Users/alaricwimer/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@salesforce/command/lib/sfdxCommand.js:97:13)\n at async Config.runCommand (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/node_modules/@oclif/config/lib/config.js:172:9)\n at async Main.run (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/node_modules/@oclif/command/lib/main.js:22:9)\n at async Main._run (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/node_modules/@oclif/command/lib/command.js:43:20)\n at async Object.run (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/dist/cli.js:32:20)",
"warnings": []
}
Does anyone know how I can fix this?
Your version was correct nevertheless (the most recent). You had verified it yet (previous message) that suggested a "correct" installation but it was corrupted after all.
All Answers
1) I have the same error frequently. That could be just one new "bad" static resource (for sfdx) that you cannot retrieve anymore.
2) There are also some recent metadata types that could be still unavailable if your sfdx CLI has not been updated recently. What is you version?
sfdx --version
3) Did you create a project with a manifest? You can remove the member of the static resource from the package.xml and retry.
4) You can activate this flag --loglevel=TRACE for many sfdx commands to see more internal details (and --json for post-processing of the result).
1. I have created two new SFDX projects, one with manifest, and one without. Both give the same error when running sfdx commands. Even simple ones like sfdx force:org:list
2. My SFDX Version = sfdx-cli/7.69.0-c7be45ae22 darwin-x64 node-v12.18.3
3. I removed Static Resources from package.xml for my project with manifest, and same error occurs.
4. when I run sfdx force:org:list --loglevel=TRACE --json, here is my output: https://prnt.sc/ty0hdi
5. When I run npm install -g sfdx-cli to update npm, I get this response: https://prnt.sc/ty0jur
It's very strange that this started happening all of a sudden. I can't think of anything I did to cause this. But now, all my projects and new projects are affected.
Any other help or guidance you have would be greatly appreciated. Thanks again.
4. const lifecycle = core_1.Lifecycle.getInstance();
core_1 is undefined or incomplete in your case (I don't know why)
You can modify: C:\Users\...\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\salesforce-alm\node_modules\@salesforce\command\lib\sfdxCommand.js
All the SFDX commands are javascript files and we can change them for a try with new console.log commands like above.
console.log('>>> eventName:' + eventName);
console.log(">>> " + prop)
My results for core_1 : Lifecycle is well defined here.
It is related to the command OrgListCommand.
What is your result of "sfdx force:org:list" ?
Your version was correct nevertheless (the most recent). You had verified it yet (previous message) that suggested a "correct" installation but it was corrupted after all.