How to fix TypeError: target.extend is not a function mixins in Magento 2?

I am working on the checkout page store locator popup modal, I have tried to mixins for the pickup-locations-service.js file to override core methods from the javascript file.

The error TypeError: target.extend is not a function in Magento 2 often occurs due to issues with JavaScript mixins declaration.

Due to incorrect syntax in my custom mixins javascript file, I got the error in the browser console file,

target.extend is not a function.

This error came due to invalid syntax in your mixins file. you need to fix the mixins JS file to resolve that error.

I have created mixins syntax in the requirejs-config.js file like this,

var config = {
    config: {
        mixins: {
            'Magento_InventoryInStorePickupFrontend/js/model/pickup-locations-service': {
                'Rbj_StorePickupModal/js/model/pickup-locations-service-mixin': true
            }
        }
    }
};

Magento_InventoryInStorePickupFrontend/js/model/pickup-locations-service javascript file has a getLocation() method that needs to be overridden in my custom module.

This is the correct way to fix the above target.extend issue,
Create custom mixins in the module called Rbj_StorePickupModal,
Rbj_StorePickupModal/view/frontend/web/js/model/pickup-locations-service-mixin.js file.

define([], function () {
    'use strict';
    return function (target) {
        target.getLocation = function (sourceCode) {
            // console.log(sourceCode);
            //WRITE_YOUR_CUSTOM_JAVASCRIPT_CODE
        }

        return target;
    };
});

With the above way, you can fix the browser console error.

By ensuring that the mixin is properly defined, and included and that the target is a valid Magento UI component, you can resolve the TypeError: target.extend is not a function error.

You can also be interested to read about some mixins article.