+ Start a Discussion
Ravi_SFDCRavi_SFDC 

LWC Issue

I am getting the below error when i am trying to deploy the code from locale tot he scratch org

This error comes when i created a custom label in the Lightning Web Component.
Labels should have a section and a name: ProgramOverview
Ajay K DubediAjay K Dubedi
Hi Ravi,

To import Custom Labels we use @salesforce/label scope module in Lightning Web Components

import labelName from '@salesforce/label/labelReference';

labelName  ---> it is a name that refers to the label.
labelReference ---> The name of the label in your org in the format namespace.labelName

Note:
if you don't have any namespace in your org use default namespace c
Ex: c.labelReference

You can take idea for following Example:
CustomLabelDemo.html
--------------------

<template>
    <lightning-card  title="Custom Label Example" variant="narrow" icon-name="standard:opportunity">
        <p>{label.WelcomeLabel}</p>
    </lightning-card>
</template>


CustomLabelDemo.js
------------------

import { LightningElement } from 'lwc';

// importing Custom Label
import WelcomeLabel from '@salesforce/label/c.SalesforceCodeCrack';
export default class CustomLabelDemo extends LightningElement {
    label = {
        WelcomeLabel,
    };
}

CustomLabelDemo.js-meta.xml
---------------------------

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="CustomLabelDemo">
    <apiVersion>45.0</apiVersion>
    <isExposed>false</isExposed>
    <targets>
        <target>lightning__AppPage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__HomePage</target>
    </targets>
</LightningComponentBundle>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Ravi_SFDCRavi_SFDC
Hi Ajay,

Thank you, I found the solution.
raviteja p 38raviteja p 38
Hi Ravi,

What is the solution?? I'm facing the same issue now.
Ravi_SFDCRavi_SFDC
Hi Ravi,

I am not able to recollect, but can you provide the details of your issue along with the error screen shot that you are facing. So that i can check and tell you.
awinash kumarawinash kumar
For me this error showed up because I'd missed to include namespace(c) in the import statement.
import labelName from '@salesforce/label/labelReference';
labelReference: The name of the label in your org in the format namespace.labelName.
For example - 
import editLabel from '@salesforce/label/c.Edit';
Notice the namespace - c in the import statement, if you dont use it, you will get an error - Labels should have a section and a name: