I am trying to use Static resource inside the lightning web component. while importing getting this error:- "Invalid reference SDFCImages of type resourceUrl in file StaticResourceDemo.js"

here how I import static resource in LWC.


import { LightningElement, track, } from 'lwc';                                                                                                                  
import SFDC_Images from '@salesforce/resourceUrl/SDFCImages';  
export default class StaticResourcesDemo extends LightningElement {  
    Sfdcimage1 = SFDC_Images + '/images/1518.png';  
    Sfdcimage2 = SFDC_Images + '/images/Capture.png';  
    someCode="Static Resources";  

how my static resource looks like on Salesforce...enter image description here

  • anybody here to answer? – Vaishali Garg Jan 23 '19 at 10:50
  • 1
    Are you sure that screenshot is from the same scratch org that you're trying to push to? Your code works for me but I do get that error if the static resource doesn't exist in the org yet. – John Towers Jan 23 '19 at 14:04
  • @VaishaliGarg so what fixed it? Can you close your question if it's not valid? – citizen conn Jan 25 '19 at 10:35
  • @citizen I don't know. how to close question. please help me to close this one. – Vaishali Garg Jan 25 '19 at 11:34
  • @VaishaliGarg Just answer it yourself with the fix that resolved it, so if someone else comes across this they might know why – citizen conn Jan 25 '19 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.