Salesforce CLI – SFDX – Cannot read properties of undefined (reading ‘id’)

Salesforce CLI – SFDX – Cannot read properties of undefined (reading ‘id’)
When running the command that makes the login against our Sandbox org, it redirects to a localhost URL and then it display an error that doesn’t give us so much information
      sfdx auth:web:login -a myuser@abc.com --instanceurl=https://xxxxx--xxxxx.my.salesforce.com
    

The error

Cannot read properties of undefined (reading ‘id’)
This is most likely not an error with the Salesforce CLI. Please ensure all information is accurate and try again.
This error can be related to the enhanced domain enabled or just the wrong URL typed in the login command. Read more about
Enhanced Domain enabled https://help.salesforce.com/s/articleView?id=sf.domain_name_enhanced_enable.htm&type=5

Solution

To fix this error, add just “sandbox” to the URL so the pattern must be “xxxxxx–xxxx.sandbox.my.salesforce.com”

      sfdx auth:web:login -a myuser@abc.com --instanceurl=https://xxxxxx--xxxx.sandbox.my.salesforce.com
    
Photo by Markus Spiske on Unsplash