9

I am not sure what this error is and if it is affecting anthing, however this is coming into my console:

layout.js:64 Uncaught TypeError: Constr is not a constructor (layout.js line 64)
2
  • I'm having the very same problem. Can you give more information on this?
    – Max
    Commented Aug 2, 2016 at 15:08
  • I'm having the same problem.got the solution?
    – Mahendra
    Commented Apr 10, 2019 at 13:27

5 Answers 5

16

For anyone who might encounter this problem as well: I had the same problem with my custom JavaScript components. It turned out a small typo in my JS files was causing the problem. Instead of define() I used require() on top. So to wrap it all up, here's a boilerplate for a custom JavaScript component:

define([
  'uiComponent'
], function(
  uiComponent
) {
  "use strict";

  /**
   * Return the UI Component
   */
  return uiComponent.extend({
    /**
     * Initialization method
     */
    initialize: function () {
      this._super();
    }
  });
});
2
  • Thanks, same here. Happend when I ported some non-UI-component code which used require before to a component.
    – Alex
    Commented Nov 23, 2017 at 18:38
  • Thanks, that was my issue too Commented Mar 2, 2022 at 15:40
2

This is a bug in the agreement-validator JS. (vendor/magento/js/module-checkout-agreements/view/frontend/web/js/view/agreement-validation.js)

Here you see: //return Component.extend({}); This should be uncommented because it breaks the second parameter of the fire function of jquery. Not sure if it breaks something else though, but the result of this, is this error and in some cases when the terms and agreements are set to manually, the order button will not work.

Until this is fixed by Magento, you can create an override for this JS in you own theme folder. To do this, add the following file:

app/design/frontend/<ThemeNameSpace>/<Theme>/Magento_CheckoutAgreements/web/js/view/agreement-validation.js and paste the contents of vendor/magento/js/module-checkout-agreements/view/frontend/web/js/view/agreement-validation.js into it. Uncomment the return and redeploy the static content.

1
  • 1
    In 2.2.4 that line uncommented, but error still appears.
    – vaso123
    Commented May 25, 2018 at 11:36
0

I have faced the same issue. The cause of the issue i have declared same js file location which is already used in Core file.

For example, I have tried to restructure the order summary totals blocks by using my custom js file like,

"components": {
     "block-totals": {
              "component": "Magento_Checkout/js/summary/totals",                          
                  }
             }

But in the same location already a totals.js exist in magento-checkout/frontend/web/js/summary/totals.js.

Then I have renamed the file name like,

"component": "Magento_Checkout/js/summary/showtotals",

Now I don't have any errors !! and my order summary totals block overwritten.

0

For me, I was using a Magento Js Mixin and required the template adjusted slightly differently as described in the Magento docs here: https://devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/js_mixins.html

0

After upgrading a Magento installation from 2.1.x to 2.3.x, very same JS error was triggered by a custom JS rewrite (of a Magento core RequireJS alias) requiring an update. Next changes resolved the JS error in my case:

File: Vendor/Module/view/frontend/requirejs-config.js

var config = {
-    paths: {
-        alias: 'Vendor_Module/js/complex/path/amd-module',
+    map: {
+        '*' : {
+            alias: 'Vendor_Module/js/complex/path/amd-module'
+        }
     },
     config: {
         mixins: {

Having the require JS alias rewrite moved to the correct config made the Uncaught TypeError: Constr is not a constructor error disappear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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