[SalesForce] No MODULE named markup://c:pubsub found in lwc

i am trying to make communicate component with each other which are independent(nonrelated), when i am trying to push source to org it showing error 'No MODULE named markup://c:pubsub found : [markup://c:meetingRoom]'. Please help me with it. Thank you. here is my code:

selectedMeetingRoom.html

<template>
    <lightning-card title="Meeting Room">
        You Have Selected : {selectedMeetingRoom.roomName}
        You Have Selected : {selectedMeetingRoom.roomCapacity}
    </lightning-card>
</template>

selectedMeetingRoom.js

import { LightningElement, wire } from 'lwc';
import {registerListener, unregisterAllListeners} from 'c/pubsub' ;
import {CurrentPageReference} from 'lightning/navigation';


export default class SelectedMeetingRoom extends LightningElement {
    selectedMeetingRoom;

    @wire(CurrentPageReference) pageRef;

    connectedCallback(){
        registerListener('pubsubtileclick', this.onMeetingRoomSelectHabdler, this);
    }

    disconnectedCallback(){
        unregisterAllListeners(this);
    }

    onMeetingRoomSelectHabdler(payload){
        this.selectedMeetingRoom = payload;
    }
}

meetingRoom.html

<template>
    <lightning-card title="Meeting Rooms">
        <lightning-layout>
            <lightning-layout-item size="4" padding="around-small">
                <ul>
                    <template for:each={meetingRoomsInfo} for:item="room">
                    <li key={room.roomName} style="padding: 10px">
                        <c-meeting-room meeting-room-info={room} show-room-info ></c-meeting-room>

                    </li>
                    </template>
                </ul>
            </lightning-layout-item>
            <lightning-layout-item>
                You Have Selected : {selectedMeetingRoom}
            </lightning-layout-item>
        </lightning-layout>

</lightning-card>
</template>

meetingRoom.js

import {LightningElement, wire, api} from 'lwc';

import {CurrentPageReference} from 'lightning/navigation';

import {fireEvent} from 'c/pubsub';

export default class MeetingRoom extends LightningElement {
    @api meetingRoomInfo;

    @api showRoomInfo = false;

    @wire(CurrentPageReference) pageReference;

    tileClickHandler(){
        const tileClicked = new CustomEvent('tileclick', {detail : this.meetingRoomInfo, bubbles:true});

        this.dispatchEvent(tileClicked);
        fireEvent(this.pageReference, 'pubsubtileclick', this.meetingRoomInfo);
    }
} 

meta files are set to true for isExposed in both.

Best Answer

The pubsub module is not a standard module provided by Salesforce. The LWC developer docs states to copy the module from the lwc-recipes repo:

IMPORTANT The Lightning web components sample repositories include a pubsub module. Copy the pubsub module and use it in your code.

You will need to create the component in your org.

Related Topic