1

Working in LWC, after weeks on this component, I'm now getting this error that won't allow me to push to scratch.

[Line: 993, Col: 0] LWC1503: Parsing error: Only one default export allowed per module. (993:0)

Line 993 is the last line in this very long js -- which is why I'm not pasting the entire thing here.

I searched for "export" -- there's only one instance of the word. There are no other formatting issues flagged in the Problems tab (other than this one).

export default class Reactor extends LightningElement {

I have correctly formatted {} throughout, and a closing curly bracket at the end.

Anybody seen this issue before?

UPDATE: I tried using sfdx force:source:deploy -p force-app/main/default/lwc/reactor and while it didn't deploy, it DID provide a more prescriptive error message, which points me to the js-meta.xml file.

This is a container component, so it's exposed and has configuration properties, which I edited this morning. I've deleted the component from pages on my scratch, but I'm still working through it.

The problem seems to be that I can't remove targets for lightning_HomePage and lightning_AppPage -- even though I don't need them on those pages. It's telling me that the component is in use on those pages in the org...

And, it won't let me change the name of one of my properties -- says that property is in use on the pages.

You can't remove the property tag named 'campaignFilter' specified in targetConfig lightning__RecordPage. The component is in use on a Lightning page.
You can't remove the property tag named 'campaignFilter' specified in targetConfig lightning__AppPage. The component is in use on a Lightning page.
You can't remove the property tag named 'campaignFilter' specified in targetConfig lightning__HomePage. The component is in use on a Lightning page.

Where would that be showing up?

  • 1
    We'd probably have to see the code, unfortunately. You shouldn't get this error unless you have more than one default export. – sfdcfox May 24 at 19:11
  • Exactly. I don't think it's reasonable to expect others on this forum to proof read a thousand lines of code for me. The error is specific -- it thinks it know what it's about, but I think it's wrong. I swear, there's only one export. I was hoping someone else might have seen this and would be able to say "Oh, that happens when...". – PatMcClellan__c May 24 at 19:17
  • Yeah, I don't have enough experience with LWC to have triggered this bug, assuming there is one. Troubleshooting this would actually consist of deleting functions a few at a time until the error goes away, the back up a step and troubleshoot from there. However, it could take a lot of effort to get to that point, because functions can call other functions, etc. – sfdcfox May 24 at 19:35
  • My suggestion is to try deploying to a new scratch org and see if you still get the issue. – Phil W May 25 at 8:13
0

Mea culpa. Turns out, the error message knew exactly what it was talking about.

I have a component called Reactor, which drops into a Campaign record page and uses that recordId to access CampaignMember records. I wanted to create the same functionality for non-Campaign lists, so I created a component called listReactor, which takes other @api inputs. Since it does so much of the same stuff, I copied/pasted the js file and started making my changes.

Except I forgot to change the name of the default export method.

I quickly decided that it would be cleaner design if I just made my Reactor component a bit smarter, and used the js-meta.xml file to handle taking different inputs based on context. So I updated all of that and tried to push it -- forgetting that I hadn't deleted the listReactor component and its export method with the name Reactor.

Doh!

  • Hey Pat, if you wanted to avoid cludgyness, could you not create a base class and have the two components extend it? – Phil W May 25 at 21:25
  • @PhilW, yeah, probably... if I were experienced enough in LWC. I haven't learned to extend JS yet. :) It really wasn't that hard to adapt the single component to 2 situations. I just used (at)api objectApiName and evaluated that. – PatMcClellan__c May 25 at 23:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.