3

Note: Checking this potential duplicate didn't help.

I have a project which uses SFDX and LWC and recently converted it to have a namespace (later it should become a Managed Package). I successfully recreated the scratch org and pushed my yet unprefixed code to it:

I then added the namespace to my import statements

import { LightningElement, api, track } from "lwc";

import getAccounts from "@salesforce/apex/MyCtrl.getAccounts";

export default class AccountList extends LightningElement {
 ...
}

Now all Apex calls from LWC js are failing with:

apex://myns.MyCtrl: No apex action available for myns.MyCtrl.getAccounts

When I add the namespace to my import statements:

import { LightningElement, api, track } from "lwc";

import getAccounts from "@salesforce/apex/myns.MyCtrl.getAccounts";

export default class AccountList extends LightningElement {
 ...
}

I get a compile-time error stating:

Error:(1, 1) LWC1504: Invalid module id "myns.MyCtrl.getAccounts" for type "apexMethod". Explicit use of namespace "myns" in file "accountList.js" is prohibited. Use default namespace "c" instead.

  • Did something go wrong with my scratch org?
  • I can see the namespace being active in there. It's on all the classes?
  • I expected to not have to explicitly mention namespace in a namespace org!?
4

Something was wrong with my scratch org. After I recreate it 2 times it worked without adding any namespaces. I didn't delete my question as this might happen others and then the thread is helpful.

Thanks for everybody's help!

| improve this answer | |

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.