[SalesForce] Unable to deploy source to dev-hub enabled org

as part of doing Push and Deploy Lightning Web Component trail (https://trailhead.salesforce.com/content/learn/modules/lightning-web-components-basics/push-lightning-web-component-files), I have been trying to deploy source to my dev hub enabled org with following command:

sfdx force:source:deploy -p force-app -u <my org user name>

But I am getting below errors:

PROJECT PATH                                                                                       ERROR
─────────────────────────────────────────────────────────────────────────────────────────────────  ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
force-app/main/default/navigationMenus/Default_Navigation.navigationMenu-meta.xml                  Not available for deploy for this organization
force-app/main/default/networks/E-Bikes.network-meta.xml                                           Not available for deploy for this organization
force-app/main/default/objects/Case/fields/Product__c.field-meta.xml                               Cannot update a field to a Lookup, MasterDetail, or Hierarchy from something else (44:13)
force-app/main/default/objects/Product_Family__c/listViews/All_Product_Families.listView-meta.xml  SharedTo not allowed:roleAndSubordinatesInternal - CEO (106:19)
force-app/main/default/objects/Account/listViews/All_Acounts.listView-meta.xml                     SharedTo not allowed:roleAndSubordinatesInternal - CEO (103:19)
force-app/main/default/flexipages/Order_Record_Page.flexipage-meta.xml                             You can't change a Lightning page's associated object.
force-app/main/default/flexipages/Product_Record_Page.flexipage-meta.xml                           You can't change a Lightning page's associated object.
force-app/main/default/sites/E_Bikes.site-meta.xml                                                 Communities must be enabled before deploying a Chatter Network Site
force-app/main/default/siteDotComSites/E_Bikes_C.site                                              You don't have the correct site publisher privileges for this operation Site : E-Bikes, type: Site.com Community(db=C,api=ChatterNetworkPicasso)
force-app/main/default/layouts/Case-Case Layout.layout-meta.xml                                    In field: QuickAction - no QuickAction named Case.CaseComment found
force-app/main/default/pages/CommunitiesLanding.page                                               Apex class 'CommunitiesLandingController' does not exist
force-app/main/default/objects/Order__c/Order__c.object-meta.xml                                   0M02v000000vrBO does not exist or is not a valid override for action View.
force-app/main/default/objects/Product__c/Product__c.object-meta.xml                               0M02v000000vrBV does not exist or is not a valid override for action View.
force-app/main/default/networkBranding/cbE_Bikes.networkBranding                                   Network not found for the CustomBrand : cbE_Bikes

I am not able to figure out regarding how to solve this. Please help.

EDIT

I have done the steps as mentioned in other posts as well:

1. Enable communities.
2. Delete the Product field from the Case object.
3. Update E_Bikes.site-meta.xml
4. Update E-Bikes Profile.profile

Now while executing the below command:

sfdx force:source:deploy -p force-app/main/default -u ebikesDE

Now I am getting below error:

PROJECT PATH                                                              ERROR
────────────────────────────────────────────────────────────────────────  ──────────────────────────────────────────────────────────────────────────
force-app/main/default/flexipages/Order_Record_Page.flexipage-meta.xml    You can't change a Lightning page's associated object.
force-app/main/default/flexipages/Product_Record_Page.flexipage-meta.xml  You can't change a Lightning page's associated object.
force-app/main/default/objects/Order__c/Order__c.object-meta.xml          0M02v000000vrBO does not exist or is not a valid override for action View.
force-app/main/default/objects/Product__c/Product__c.object-meta.xml      0M02v000000vrBV does not exist or is not a valid override for action View.
ERROR running force:source:deploy:  Deploy failed.

Best Answer

I ran into the same issue, and was able to successfully push my code by following the instructions in the "Installing E-Bikes using a Developer Edition Org" section of the README in the e-bikes repo. From your revised question, it sounds like you followed the same steps, but perhaps you missed something. It's also possible that you used an existing Developer Org, perhaps with some other existing config; I used a new Trailhead Playground org. Here are all the steps I went through, starting with the steps before the deploy issue:

  1. From Trailhead, I created a new Playground which I named "LWC Playground".
  2. I used this playground to complete the LWC Quickstart project and the "Setup Developer Tools" module, so I already had sfdx & vs code installed, and set a password for the playground's admin user.
  3. I cloned the e-bikes repo to my local machine: git clone https://github.com/trailheadapps/ebikes-lwc
  4. Since I had already added my LWC Playground to sfdx in one of the other modules, I made it the default dev hub for e-bikes. From inside the ebikes-lwc directory: sfdx force:config:set defaultdevhubusername=lwc-playground. You could also authenticate to it directly as dev hub if you haven't added it to sfdx yet: sfdx force:auth:web:login --setdefaultdevhubusername --setalias lwc-playground.
  5. In the "Push and Deploy Lightning Web Component Files" step, I followed the link to the e-bikes repo's README and followed the instructions to create a scratch org and pushed the code with no issue. Then I added the new bikeCard component and pushed it, with no issue.

Up to this point, everything worked as expected. When I tried to take the next step of pushing to my LWC Playground/Dev Hub org (sfdx force:source:deploy -p force-app -u lwc-playground), I encountered the same list of errors that you did. To resolve, I again referred to e-bikes repo's README and followed the steps for a Developer Org, as follows:

  1. As I used a Trailhead Playground, I already had a developer org with My Domain enabled (as specified in the instructions).
  2. In Setup -> Communities Settings, click the Enable communities checkbox. You have to specify a subdomain; I just used the playground's prefix (something like cunning-moose-123). Make note of this value for later.
  3. In Setup -> Object Manager -> Case, remove the Product custom field.
  4. My org was already authenticated, and I didn't bother to start a new git branch (as specified in the instructions).
  5. I edited force-app/main/default/sites/E_Bikes.site-meta.xml, changing <siteAdmin> to be my Playground org User Name (you can see this using sfdx force:org:list, and changing <subdomain> to be the subdomain I used in step 2.
  6. I edited mdapiDeploy/unpackaged/profiles/E-Bikes Profile.profile, changing the <userLicense> at the end of the file to Guest.
  7. At this point, the deploy worked (sfdx force:source:deploy -p force-app/main/default -u lwc-playground).
  8. I followed the remaining steps in the README to set perms, import data, publish the community, etc.