For now, you need to have the pre-release version installed for DX:
sfdx plugins:install salesforcedx@pre-release
Make sure you've also updated all extensions, including Lightning Web Components, which is not currently part of the Salesforce Extension Pack.
Often, simply restarting after installing/updating all extensions and the pre-release sfdx plugin will automatically create the lwc folder for you. You may also need to close and re-open the folder for it to take effect. I'm not sure how/why my lwc folder appeared, but it wasn't obvious as to what I did.
If all else fails, create a new project in a new, empty directory, and copy the lwc folder back into force-app/main/default/
, so that it has two files:
./force-app/main/default/lwc/.eslintrc.json
./force-app/main/default/lwc/jsconfig.json
Once you've done that, you'll stop getting that error and be able to create new components. These config files may require modification if you copy from a new project, so make sure you check the file paths of jsconfig.json. Every time you create a new component with sfdx, jsconfig.json will be updated with more metadata, so make sure you commit this file if you're using a repo.
NOTE: Even though you'll be able to create files locally, to push to the server, you need a pre-release org for now, since all new LWC features are tied to API 45.0 and later, while all production and scratch orgs will be 44.0.
Solved the issue by defining the targets
definition in the xml file of the lightning web component.
From the Developer Guide:
There are a few steps to take before you can use your custom Lightning web components to create a Lightning page in Lightning App Builder. One of them is Define Component Metadata in the Configuration File
The .js-meta.xml file defines the metadata values for the component, including the design configuration for components intended for use in Lightning App Builder. Edit the configuration file to:
- Define what types of Lightning pages your component can be used on.
- Configure your component’s properties.
- Set your component’s supported objects.
- Make the component usable outside of your own org.
Added Definition:
<targets>
<target>lightning__RecordPage</target>
<target>lightning__AppPage</target>
<target>lightning__HomePage</target>
</targets>
Best Answer
LWC can only be pushed on
salesforcedx 45.0.12 (pre-release)
version of Salesforce DX CLI. You have to update the CLI using the following command.Once the plugin is updated you will be able to push LWC into any Spring 19 or.
I would also recommend going though this trailhead to have a quick grasp.
Src: https://trailhead.salesforce.com/content/learn/projects/quick-start-lightning-web-components/set-up-salesforce-dx