0

We are running a Magento multi site and on ONE site only, I get this error Uncaught TypeError: $.initNamespaceStorage is not a function

All sites use the same theme (just some differences between them..), any clues ?

Thank you for helping me Here is the script

        require.config({
            deps: [
                'jquery',
                'mage/translate',
                'jquery/jquery-storageapi'
            ],
            callback: function ($) {
                'use strict';

                var dependencies = [],
                    versionObj;

                $.initNamespaceStorage('mage-translation-storage');
                $.initNamespaceStorage('mage-translation-file-version');
                versionObj = $.localStorage.get('mage-translation-file-version');

                 if (versionObj.version !== '92817ddfc8670bafd7f41084a570359ae57c4623') {
                    dependencies.push(
                        'text!js-translation.json'
                    );

                }

                require.config({
                    deps: dependencies,
                    callback: function (string) {
                        if (typeof string === 'string') {
                            $.mage.translate.add(JSON.parse(string));
                            $.localStorage.set('mage-translation-storage', string);
                            $.localStorage.set(
                                'mage-translation-file-version',
                                {
                                    version: '92817ddfc8670bafd7f41084a570359ae57c4623'
                                }
                            );
                        } else {
                            $.mage.translate.add($.localStorage.get('mage-translation-storage'));
                        }
                    }
                });
            }
        });
3
  • Please replace your $ with jQuery and also share some code related to that place. Commented May 4, 2021 at 10:44
  • Here is the error : ----------------------------------------- (index):233 Uncaught TypeError: $.initNamespaceStorage is not a function at callback ((index):233) at Object.execCb (require.js:114) at Module.check (require.js:56) at Module.<anonymous> (require.js:73) at require.js:11 at require.js:75 at each (require.js:3) at Module.emit (require.js:75) at Module.check (require.js:61) at Module.<anonymous> (require.js:73) -------------------------------------------
    – JG Cabanas
    Commented May 4, 2021 at 11:42
  • Have you check the jquery version? In my case there is a jquery clash loading in a module that creating this problem
    – Marbonka
    Commented Dec 16, 2021 at 13:00

1 Answer 1

2

This is because jquery/jquery-storageapi might not have been loaded already. To fix the issue, vendor/dhl/module-ui/view/frontend/web/js/model/checkout/storage.js needs to require jquery/jquery-storageapi in its define like:

define([
    'jquery',
    'Magento_Checkout/js/model/quote',
    'jquery/jquery-storageapi'
], function ($, quote) {

Get Detailed Reference Here - https://github.com/netresearch/dhl-module-ui/issues/4
Thanks
Vibhore

2
  • Yes but Magento_Dhl module is not enabled...
    – JG Cabanas
    Commented May 4, 2021 at 12:43
  • If you can enable Dhl module then do that, otherwise what is your module name you can enable that. Commented May 4, 2021 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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