function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dwayne JacksonDwayne Jackson 

How to resolve - LWC1011: Failed to resolve import "../ldsUtils/ldsUtils" from "accountList.js". in the Handle Server Error Trailhead

Hi, I'm implementing the Lightning Web Components and Salesforce Data -> Handle Server Errors part of theTrailhead module.
 
The instructions say…
Handle Errors in the accountList Component
Let’s add error handling to the accountList component that you created.
  1. In the accountList.html file, after the <template> that includes the lightning-datatable, add this code:
    <template if:true={errors}>
        <p>{errors}</p>
    </template>

    Copy
  2. Copy the ldsUtils component from LWC recipes and include it in the force-app/main/default/lwc folder in your project. This component contains the reduceErrors function.
  3. Import the reduceErrors function near the beginning of accountList.js.
    import { reduceErrors } from 'c/ldsUtils';
    Copy
  4. In accountList.js, insert this getter, which defines an errors property:
    get errors() {
        return (this.accounts.error) ?
            reduceErrors(this.accounts.error) : [];
    }

    Copy
 
 
My issue is in step 2 and 3. I copied the ldsUtils component as instructed, but following problem shows up in Visual Studio Code Output panel and I cannot deploy it to my dev instance:
 
 
=== Deploy Errors
PROJECT PATH  ERRORS                                                                                                                                         
────────────  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
              LWC1011: Failed to resolve import "../ldsUtils/ldsUtils" from "accountList.js". Please add "../ldsUtils/ldsUtils" file to the component folder.
 
 
So I changed the import in the accountList.js from:
import { reduceErrors } from 'c/ldsUtils';
To
import { reduceErrors } from '../ldsUtils/ldsUtils';
 
The ldsUtils component is in the same component folder as the rest of my LWC components, which is:
C:\...lwc-tutorials\workingWithDataInLWC\force-app\main\default\lwc\ldsUtils
 
Any help as to what I'm doing is wrong. Thanks in advance.
 
VinayVinay (Salesforce Developers) 
Please note that Questions about how to pass Trailhead challenges are not on topic, because these challenges are intended to be independent demonstrations of your abilities.

Trailhead Help (https://trailhead.salesforce.com/en/help?support=home)can provide assistance for situations where Trailhead does not appear to be functioning correctly. You can reach out to them if this is the case.

Thanks,
Dwayne JacksonDwayne Jackson
@Vinay, thank you for the reply. Let me clarify if I may, my intention of the question is not how to pass the trailhead. I followed the instructions explicitly and it's not working.The purpose of the trailhead is to develop a new skill but if it's not working how can one accomplish this. It's also a good thing to understand how to troubleshoot an issue when it occurs. Thanks for the feedback. I'll try the Trailhead Help.
VinayVinay (Salesforce Developers) 
Thanks and I understand your concern.

Kindly reach out trailhead team (https://trailhead.salesforce.com/en/help?support=home) and they can help you.

Please mark as Best Answer if above information was helpful so that it can help others in the future.

Thanks,
Srajat MathurSrajat Mathur
Hi @Dwayne Jackson,

Were you able to clear this badge buddy? I'm facing the same issue.
Kameron WisozkKameron Wisozk
After reading this amazing and informative post I want to request you for written one blog about psa oxygen concentrator suppliers (https://cantamedical.com/product/psa-oxygen-concentrator-suppliers/) as I am searching for the best post here but I can't find the quality posts.
Stephen Wilcox 3Stephen Wilcox 3
For anyone else who runs into this error, simply deploy the ldsUtils component first (downloaded from the link to GitHub).  Then deploy the accountList component.
Neha PeerthyNeha Peerthy
Step1:- Create a LWC named "ldsUtils"
****Step2: Paste the Below Code as given in ldsUtils.js ****
/**
 * Reduces one or more LDS errors into a string[] of error messages.
 * @param {FetchResponse|FetchResponse[]} errors
 * @return {String[]} Error messages
 */
export function reduceErrors(errors) {
    if (!Array.isArray(errors)) {
        errors = [errors];
    }

    return (
        errors
            // Remove null/undefined items
            .filter((error) => !!error)
            // Extract an error message
            .map((error) => {
                // UI API read errors
                if (Array.isArray(error.body)) {
                    return error.body.map((e) => e.message);
                }
                // UI API DML, Apex and network errors
                else if (error.body && typeof error.body.message === 'string') {
                    return error.body.message;
                }
                // JS errors
                else if (typeof error.message === 'string') {
                    return error.message;
                }
                // Unknown error shape so try HTTP status text
                return error.statusText;
            })
            // Flatten
            .reduce((prev, curr) => prev.concat(curr), [])
            // Remove empty strings
            .filter((message) => !!message)
    );
}
Step3: Don't make any changes in "ldsUtils.html" and "ldsUtils.js-meta.xml" files
Step4: Deploy the "ldsUtils" Component to your Org
Step5: After this deploy the component in which you mentioned "ldsUtils"as "import { reduceErrors } from 'c/ldsUtils';"
Step6: Your issue is resolved