0

New to the magento 2 I am getting error JS while loading page, Any one know what exactly this issue.

Unable to resolve the source file for 'frontend/Magento/luma/en_US/modulename.js'
#0 C:\xampp\htdocs\modulename\vendor\magento\framework\App\StaticResource.php(97): Magento\Framework\View\Asset\File->getSourceFile()
#1 C:\xampp\htdocs\modulename\vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\StaticResource->launch()
#2 C:\xampp\htdocs\modulename\pub\static.php(13): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\StaticResource))
#3 {main
0

Check your js config in requirejs-config

var config = {
    map: {
        '*': {
            yourJS:       'NameSpace_ModuleName/js/yourfile',
            yourJS2:      'NameSpace_ModuleName/folder/yourfile2'       
        }
    },

};

Real Path to your js in module is
first one : NameSpace_ModuleName/view/area/web/js/yourfile.js
yourJS2 NameSpace_ModuleName/view/area/web/folder/yourfile.js

area is frontend, base, adminhtml

Call yourJS

<script type="text/javascript">
    require(['yourJS'], function(){ // Do something here });
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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