6

I am currently working in a dev org and I have installed the LWC e-bike component (https://github.com/trailheadapps/ebikes-lwc/tree/master/force-app/main/default/lwc/orderBuilder)

When I create the sfdx project and retrieve the metadata the folder for LWC is empty.

If I create a new LWC through sfdx, it is created without a problem, however, I notice that it is not like lightnining components, were if you manually delete a file you can right click in the folder and hit retrieve and the files appears again.

Is there a trick to be able to retrieve these metadata?

I have added the below into the manifest, as that is what the documentation says that represent the Lightning web component bundle

<types>
    <members>*</members>
    <name>LightningComponentBundle</name>
</types>

But it doesnt do a thing

EDIT This is my current version when i run

sfdx plugins --core

enter image description here

3
  • Are you using the latest version of the CLI ? If you run "sfdx plugins --core", what versions are you using ? Commented Feb 11, 2019 at 9:16
  • @FabienTaillon I have added an image with the result of running "sfdx plugins --core", I am pretty sure I am running the latest one
    – manza
    Commented Feb 11, 2019 at 22:34
  • Can you try to uninstall the pre-release (sfdx plugins:uninstall salesforcedx) ? Since yesterday LWC is part of the core sfdx CLI, maybe you'll need to run sfdx update but the pre-release isn't needed anymore. Also, are you on Windows ? There is an ongoing bug currently: github.com/forcedotcom/salesforcedx-vscode/issues/1023 Commented Feb 12, 2019 at 9:16

3 Answers 3

9

You can even use :

$ sfdx force:source:retrieve -m LightningComponentBundle
1
  • 2
    This worked for me. Thanks :)
    – Sree
    Commented Aug 30, 2019 at 5:45
2

There is ongoing bug which is promised to be fixed on the 21 Feb 2019.

Meanwhile you can use the following workaround.

Create package.xml file with the following content

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">

    <types>
        <members>*</members>
        <name>LightningComponentBundle</name>
    </types> 
    <version>45.0</version>
</Package>

for example, in force-app folder.

Then create file retrieve.bat in the same force-app folder with the following content.

call sfdx force:mdapi:retrieve -w 5000 -k package.xml -r . 
unzip unpackaged.zip
del unpackaged.zip
rem move unpackaged/lwc/* main/default/lwc
mv unpackaged/lwc/* main/default/lwc
rd /s/q unpackaged

Then close your VS Code and open force-app folder in Git Bash terminal and execute there

./retrieve.bat

And the missed LWC files will be restored.

See this in action: See this in action

1

You can use cli command for all the LWC components:

$ sfdx force:source:retrieve -m LightningComponentBundle

To retrieve any specific LWC component:

$ sfdx force:source:retrieve -m LightningComponentBundle:<componentName>

More details here

You must log in to answer this question.

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