Exception:
Labels should have a section and a name
Resolution:
This exception is thrown when the custom label import in the Salesforce Lightning Web Component declaration is incorrect.
Sample Lightning Web Component:
HTML:
<template>
<lightning-card>
{sampleLabel}
</lightning-card>
</template>
JavaScript:
import { LightningElement } from 'lwc';
import Sample_Label from "@salesforce/label/c.Sample_Label";
export default class SampleLightningWebComponent extends LightningElement {
sampleLabel = Sample_Label;
}
js-meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>62.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__Tab</target>
</targets>
</LightningComponentBundle>
I faced this exception when I missed the c namespace. So, use c.Sample_Label instead of just Sample_Label.