9 votes
Accepted

what is requirejs-config.js in Magento2?

Shim: To build a dependency on the third-party plugin, specify a [shim] in the following configuration files: requirejs-config.js var config = { "shim": { "3-rd-party-plugin": ["jquery"] ...
Ansar Husain's user avatar
  • 3,409
7 votes
Accepted

Magento 2 - Override Mixin with another Mixin

You can disable original mixin and enable yours by putting this snippet in your module's requirejs config: var config = { config: { mixins: { 'mage/validation': { ...
Michał Biarda's user avatar
4 votes
Accepted

How can I get the locale inside a requirejs-config file?

You should pass the value in the template In your .phtml template require([ "https//maps.googleapis.com/maps/api/js?key=mykey&libraries=places&language=<?php echo $block->...
Khoa TruongDinh's user avatar
4 votes
Accepted

Add js to module via requirejs doesn't work?

I think you need to delete var/view_preprocessed and run a php bin/magento setup:static-content:deploy (or deploy static assets via your workflow) as it works fine for me. I wouldn't recommend ...
Ben Crook's user avatar
  • 15.7k
4 votes
Accepted

Cookiebot throwing console errors in Magento 2.3.4

Create a JS file here replacing VENDOR/THEME with your theme name - app/design/frontend/VENDOR/THEME/Magento_Theme/web/js/cookiebot.js and populate it with the below content: require([ 'https://...
Ben Crook's user avatar
  • 15.7k
4 votes

jquery.mobile.custom js file error after upgrade to Magento 2.4.4

jquery.mobile.custom js is removed from magento 2.4.4. You should to look for another solution
Andzejs Nereds's user avatar
3 votes
Accepted

Requirejs urlArgs paramater in the requirejs-config.js file redirects all the min.js file requests to full .js file urls

I have found a solution to this issue. I will say it is not a perfect solution, the below solution has solved my issue, so i am posting it here so that it can help others facing this issue. Cause of ...
Sourabh Kumar Sharma's user avatar
3 votes
Accepted

Magento 2 Passing Php Variable to external js for custom theme

I got this working using this define([ 'jquery' ], function ($) { console.log('adsa'); return function (config) { console.log(config.contacturl); } }); Though I am not sure why ...
Amit Singh's user avatar
  • 1,765
3 votes
Accepted

Magento 2: How do I rewrite JS from Third Party loaded through requirejs-config.js

So in order for me to do that I had to build a module following the structure: app/code/MageCheck/Shopby/composer.json { "name": "magecheck/shopby", "description"...
Chiriac Victor's user avatar
3 votes

TypeError: require.config is not a function in Magento 2

Please check mod_rewrite enabled in your server and also check the directory symlinks like this in your server. Open /etc/apache2/apache2.conf <Directory /var/www/> Options Indexes ...
Jeeva Chezhiyan's user avatar
3 votes
Accepted

Magento 2 - How to override frontend javascript file

Magento provide 2 way of override js file. map mixin Mixin is quite complicate and map is really easy to understand. For override js file first you have to create module. To create custom module you ...
Hiren Patel's user avatar
3 votes

Magento 2 - Override Mixin with another Mixin

I was able to solve it thanks to @Michał Biarda. There was a bug in the extension Dotdigitalgroup_Sms, they forgot to return $.mage.validation. So I have overriden it by mapping and fixed it. But ...
Black's user avatar
  • 3,330
3 votes

jquery.mobile.custom js file error after upgrade to Magento 2.4.4

jquery.mobile.custom was removed from Magento Theme in Magento 2.4.4 onwards. PR: https://github.com/magento/magento2/pull/33107 Commit: https://github.com/magento/magento2/commit/...
Mukesh Chapagain's user avatar
2 votes

Magento 2 - Extend catalogAddToCart widget

try use mixins, Create a module and add files as below: app/code/Vendor/Module/view/frontend/requirejs-config.js var config = { config: { mixins: { 'Magento_Catalog/js/catalog-add-to-...
Jonas  Chen's user avatar
2 votes
Accepted

Magento 2 : Override 'Magento_Checkout/js/view/billing-address.js' with Custom JS

Solution: In your modules config.xml file add the following: Example/Module/etc/config.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
Nikunj Vadariya's user avatar
2 votes
Accepted

how to i add a javascript file in magento 2 module and how to call it in phtml?

Create requirejs-config.js under app/code/[Vendor]/[Module]/view/frontend and the below code: var config = { map: { '*': { custom: 'Vendor_Module/js/custom', } } };...
Sukumar Gorai's user avatar
2 votes

Magento2 override module-ui base admin template file?

To override the template you just need to create Magento_Ui directory in your theme folder and place file in that folder. like : app/design/frontend/vendor/theme/Magento_Ui/web/templates/grid/...
Naveed Asim's user avatar
  • 3,637
2 votes
Accepted

Constr is not a constructor on layout.js line 137 error custom module

You should avoid the copy-paste technique as much as possible. In your requirejs-config.js you are declaring that you would like to apply mixins to Magento_Checkout/js/view/billing-address with ...
Marjan's user avatar
  • 1,139
2 votes

Constr is not a constructor on layout.js line 137 error custom module

I am not sure whether this is the correct answer or not but this fix the issue hope it will help someone so I am posting here . Made changes to requirejs-config.js and the error I was facing is ...
Mac's user avatar
  • 573
2 votes

Magento 2 : Use of shims in requirejs-config.js file

As per my understanding, basically shim is used to avoid dependency conflict. For example if you calling a custom javascript then it must be loaded after javascript library isn't it? but magento ...
Prathap Gunasekaran's user avatar
2 votes
Accepted

Return all JS functions via requirejs

Rather than return the function you can return an object that contains the functions, you can them call them individually whenever you need. In this example I have 3 files: app/design/frontend/...
Ben Crook's user avatar
  • 15.7k
2 votes

how to override core JS file in module

If you want to override the Magento JS core and replace it by your custom Javascript. Step 1: Create a RequireJS configuration file requirejs-config.js var config = {  "map": {    "*": {      "&...
Muhammad Hasham's user avatar
2 votes

how to override core JS file in module

Found the answer var config = { config: { mixins: { '[core_module_name]/js/view/payment/method-renderer/cc-form': { '[module_name]/js/view/payment/method-...
jibin george's user avatar
2 votes
Accepted

Requirejs-config is not writable

Try to run the following commands to assign permissions: find ./pub/static -type d -exec chmod 777 {} \; Or sudo chmod -R 777 /home/vnsmenco/public_html/pub/static/ I hope your home directory looke ...
Mahmood Rehman's user avatar
2 votes

TypeError: require.config is not a function in Magento 2

please check it pub/static/ inside htaccess exits or not same path pub/media/ inside check it after all command apply it
Rv Singh's user avatar
  • 1,617
2 votes
Accepted

TypeError: require.config is not a function in Magento 2

I solved this problem by running: php bin/magento setup:upgrade php bin/magento setup:static-content:deploy
Kowsigan Atsayam's user avatar
2 votes

how come this override doesnt work magento 2

I came across the same problem. The var mixin method (in the answer above) won't work because there is a 'return storage.post' in the file. The way I did it was the following: app/code/Vendor/...
Sanne's user avatar
  • 1,316
2 votes
Accepted

Magento 2 how to add external css and js library with RequireJS?

UPDATE I mis-read the original issue. The script is probably loading, but it looks like you're expecting it to be available in the global scope. The AOS library is AMD-aware in that if it detects it'...
Brett's user avatar
  • 1,854
2 votes
Accepted

Third party js not loading in Magento 2.3.4

I think you have an issue with your requirejs-config.js file, it should be : var config = { paths: { dlmenu: 'Vendor_Module/js/jquery.dlmenu', modernizr:'Vendor_Module/js/...
Taschert's user avatar
  • 569
2 votes

How to load js file first in Magento 2

You cannot manually manage the sort order of JS files within core Magento 2 to the level you are asking for, and even if you could you do not want your file to load first as you have dependencies: '...
Ben Crook's user avatar
  • 15.7k

Only top scored, non community-wiki answers of a minimum length are eligible