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
Ayush Saxena 20Ayush Saxena 20 

Static Resources not loaded in Lightning Web Components(Error: Undefined)

Below is my code:
import { LightningElement } from 'lwc';
import { loadScript,loadStyle} from "lightning/platformResourceLoader";
import HIGHCHARTS from "@salesforce/resourceUrl/highcharts";
import HIGHMAPS from "@salesforce/resourceUrl/highmaps";
import DATA from "@salesforce/resourceUrl/data";
import DRILLDOWN from "@salesforce/resourceUrl/drilldown";
import EXPORTING from "@salesforce/resourceUrl/exporting";
import OFFLINE from "@salesforce/resourceUrl/offlineexporting";
import USALL from "@salesforce/resourceUrl/usall";
import FONTAWESOME from "@salesforce/resourceUrl/fontawesome";
export default class MAPROJECT extends LightningElement {
    
    connectedCallback() {
        
        Promise.all([
            loadScript(this, HIGHCHARTS)
                .then(() => console.log("highcharts loaded"))
                .catch(error => console.log("Error in loading highcharts"+ error)),
            loadStyle(this, FONTAWESOME)
                .then(() => console.log("font loaded"))
                .catch(error => console.log("Error in loading font" + error)),
            
            loadScript(this, DATA)
                .then(() => console.log("data loaded"))
                .catch(error => console.log("Error in loading data" + error)),
            
            loadScript(this, DRILLDOWN)
                .then(() => console.log("drilldown loaded"))
                .catch(error => console.log("Error in loading drilldown"+ error)),
                
            loadScript(this, EXPORTING)
                .then(() => console.log("exporting loaded"))
                .catch(error => console.log("Error in loading exporting"+ error)),
                    
            
            loadScript(this, OFFLINE)
                .then(() => console.log("offlineexporting loaded"))
                .catch(error => console.log("Error in loading offlineexporting"+ error)),
            
            loadScript(this, USALL)     
                .then(() => console.log("usall loaded"))
                .catch(error => console.log("Error in loading usall"+ error)),

            loadScript(this, HIGHMAPS)
                .then(() => console.log("highmaps loaded"))
                .catch(error => console.log("Error in loading highmaps"+ error))
        ])
        .then(() =>{
            this.runHighcharts();
        })
        .catch(error => {
            window.console.log("The error is: " + error);
        });
    }

Here is the image of uploaded static resources:
Static resources

Here is the Error in console:

Error

Thanks..
Suraj Tripathi 47Suraj Tripathi 47
Hi Ayush,
Greetings!

1. Setup -> Search Static Resource in the quick find box.
2. Click static resource.
3. Upload the static resource that you can use in LWC.
for refer-> https://www.sfdcpoint.com/salesforce/use-static-resource-in-lwc/

If you find your Solution then mark this as the best answer. 


Thank you!

Regards,
Suraj Tripathi
PriyaPriya (Salesforce Developers) 

Hi Ayush,

Kindly refer the below article :- 
https://newstechnologystuff.com/2019/03/16/use-static-resource-in-lightning-web-component/

If the above information helps, please mark it as best answer.

Regards,

Priya Ranjan

Ayush Saxena 20Ayush Saxena 20
Thanks For Reply..

But same error occur which is undefined. Multiple js file is not loaded in lwc. 

Any other option to upload file in lwc?
 
Nicolas SchultzNicolas Schultz
Hi, 
Same problems on multiples js file that not loaded in lwc. 

Found a solution : not import your files but create it in lwc directly into your staticResources folder and copy the content of your import file.
For exemple with charJs :
 ChartJsFileContent

Commit it into your org and it will appears into your salesforce uploaded static resources

Hope that helps
Bye
SForceBeWithYouSForceBeWithYou
My issue (not with ChartJS which was working fine, but with PptxGen JS) was resolved by enabling Lightning Web Security (LWS).

https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.security_lwsec_intro

Thank you Dmitry Bakovich 7!!

https://developer.salesforce.com/forums/?id=9062I000000XrWiQAK