Do you have below in the meta.xml file for the LWC?
<capabilities>
<capability>lightning__dynamicComponent</capability>
</capabilities>
Also, here is some sample code you can reference for dynamic components.
import { LightningElement, api } from "lwc";
import { ShowToastEvent } from "lightning/platformShowToastEvent";
import { reduceErrors } from "c/ldsUtils";
const VIEW_MAPPING = {
card: () => import("c/accountContactsCardView"),
table: () => import("c/accountContactsTableView")
};
export default class AccountContacts extends LightningElement {
// Public properties
@api recordId;
/** Component constructor that allows for importing the dynamic component */
componentConstructor;
/** The default component view */
view = "card";
// Private properties
_isLoading;
get viewOptions() {
return [
{ label: "Card", value: "card" },
{ label: "Table", value: "table" }
];
}
get isLoading() {
return this._isLoading;
}
/**
* Imports the default component
*/
async connectedCallback() {
this._isLoading = true;
try {
const { default: ctor } = await import("c/accountContactsCardView");
this.componentConstructor = ctor;
} catch (error) {
this.dispatchEvent(
new ShowToastEvent({
title: "Component Load Error",
message: reduceErrors(error).join(", "),
variant: "error",
mode: "pester",
})
);
} finally {
this._isLoading = false;
}
}
/**
* Sets the view which determines what component to display
* @param {Object} event the change event
*/
handleChange(event) {
this._isLoading = true;
this.view = event.detail.value;
VIEW_MAPPING[this.view]().then(({ default: ctor }) => {
this.componentConstructor = ctor;
}).catch((error) => {
this.dispatchEvent(
new ShowToastEvent({
title: "Component Load Error",
message: reduceErrors(error).join(", "),
variant: "error",
mode: "pester",
})
);
}).finally(() => {
this._isLoading = false;
});
}
}
Template
<template>
<div class="slds-m-around_medium">
<lightning-card title="Contacts" icon-name="standard:contact">
<lightning-combobox
name="contactsView"
label="Contacts View"
value={view}
placeholder="Select Contacts View"
options={viewOptions}
onchange={handleChange}
></lightning-combobox>
</lightning-card>
</div>
<div lwc:if={isLoading} class="slds-is-relative">
<lightning-spinner alternative-text="Loading..." variant="brand"> </lightning-spinner>
</div>
<lwc:component
ref="contactsView"
record-id={recordId}
lwc:is={componentConstructor}
></lwc:component>
</template>
lwc:dynamicsyntax in LWC OSS projects and as far as I know it's not yet available inside of Salesforce. I think you are getting an error meant to show only in LWC OSS.