Skip to main content
1 of 2
Nayem323
  • 771
  • 1
  • 8
  • 26

Magento 2 - Custom Module JS error

I am trying to add custom js file using my custom module. But getting below error in console.

Uncaught ReferenceError: Plyr is not defined
DevTools failed to load SourceMap: Could not load content for http://localhost/magento/pub/static/version1592134088/frontend/Magento/luma/en_US/Vendor_Module/js/plyr.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

My code:

app\code\Vendor\Modle\view\frontend\requirejs-config.js

var config = {
    map: {
        '*': {
            plyr: 'Vendor_Module/js/plyr'
        }
    }
};

On phtml file

<script type="text/javascript">
require(['jquery','plyr'],function($){
    const player = new Plyr('#player1', {
        fullscreen:{ enabled: true, fallback: true, iosNative: true },
        controls:['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen', 'download']
    });
});
</script>
Nayem323
  • 771
  • 1
  • 8
  • 26