[SalesForce] lwc error @salesforce/schema modules only support default imports for Custom objects

I am trying to import a custom object and I am getting the following error

'LWC1513: @salesforce/schema modules only support default imports'

here is my code for my js file.

import { LightningElement,api } from 'lwc';
import { StreetAddress } from "@salesforce/schema/Retail_Account__c.Address__c";
import { CityAddress } from "@salesforce/schema/Retail_Account__c.City__c";
import { StateAddress } from "@salesforce/schema/Retail_Account__c.State__c";
import { RetalName } from "@salesforce/schema/Retail_Account__c.Name"

export default class RetailMapSingleMarker extends LightningElement {
    @api RecordId 
    @api objectApiName

    mapMarkers = [
        {
            location: {
                Street: StreetAddress,
                City: CityAddress,
                State: StateAddress,
            },

            title: RetalName

                ,
        },
    ];
}

Best Answer

When you say import { RetalName } - this is called Named Import. This is not valid for @salesforce/schema modules since they are default exports. You need to use below:

import RETAIL_ACCOUNT_NAME from "@salesforce/schema/Retail_Account__c.Name"

This means, you are importing default Retail_Account__c.Name and assigning it to variable RETAIL_ACCOUNT_NAME.

NOTE:

You can use Named imports for a module like below:

const getTermOptions = () => {
    return [
        { label: '20 years', value: 20 },
        { label: '25 years', value: 25 },
    ];
};

const calculateMonthlyPayment = (principal, years, rate) => {
    // Logic
};

export { getTermOptions, calculateMonthlyPayment };

Here, you are exporting getTermOptions and calculateMonthlyPayment functions. So, you can import them by Name as below.

import { getTermOptions, calculateMonthlyPayment } from 'c/your_module'