javascript require is not defined code example

Example 1: require is not defined

remove "type": "module" from package.json

Example 2: require is not defined javascript

<script>
            define([
            "jquery", 
            "mage/translate", 
            "mage/adminhtml/events", 
            "mage/adminhtml/wysiwyg/tiny_mce/setup"
            ], function(jQuery){
                wysiwygCompanyDescription = new wysiwygSetup("company_description", {
                    "width":"100%",
                    "height":"200px",
                    "plugins":[{"name":"image"}],
                    "tinymce4":{"toolbar":"formatselect | bold italic underline | alignleft aligncenter alignright | bullist numlist | link table charmap","plugins":"advlist autolink lists link charmap media noneditable table contextmenu paste code help table",
                    }
                });
                wysiwygCompanyDescription.setup("exact");
            });
        </script>

Example 3: require not defined in html file

function createAddItemWindow() {

    // Create a new window
    addItemWindown = new BrowserWindow({
        width: 300,
        height: 200,
        title: 'Add Item',

        // The lines below solved the issue
        webPreferences: {
            nodeIntegration: true
        }
})}

Example 4: jQuery is not defined load-scripts.php

Try adding define('CONCATENATE_SCRIPTS', false); to your wp-config.php file just below the define('DB_HOST' line.

Tags:

Php Example