How to Override JS File in Magento 2

To override the JS file in Magento 2

Create registration.php

Directory

app\code\VendorName\ModuleName\registration.php

Content of registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(\Magento\Framework\Component\ComponentRegistrar::MODULE, 'VendorName_ModuleName', __DIR__);

Create module.xml

Directory

app\code\VendorName\Namespace\etc\module.xml

Content of module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="VendorName_ModuleName" setup_version="1.0.0"/>
</config>

Create requirejs-config.js

Directory

app\code\VendorName\ModuleName\view\frontend\requirejs-config.js

Content of requirejs-config.js

var config = 
{
map:
{
'*':
{
'Magento_Checkout/js/action/place-order':'VendorName_ModuleName/js/action/place-order'
}
}
};
If you want any kind of help please visit our Magento 2 Development Service and get a Quote.
Related Products