1

I have a Magento 2 install that is generating invalid JS files when I run php bin/magento setup:static-content:deploy. I get JS errors now on both the admin and frontend.

E.g. pub/static/adminhtml/Magento/backend/en_US/Magento_Ui/js/lib/knockout/bindings/i18n.js - SyntaxError: missing ) after argument list

 /** * execute i18n binding * @param {Object} element * @param {Function} valueAccessor * @param {bool} isUpdate */ execute = function (element, valueAccessor, isUpdate) { var original = ko.unwrap(valueAccessor() || ''), el = getRealElement(element, isUpdate), inlineTranslation = (module.config() || {}).inlineTranslation; if (inlineTranslation) { setTranslateProp(el, original); } else { setText(el, "'" .addAttribute('translate', { binding: 'i18n' }); 
3
  • Not sure if you not post your current code related to issue . Try to rm -r pub/static/frontend/* pub/static/adminhtml/* pub/static/_requirejs/* and back reload page Commented Jun 24, 2017 at 17:58
  • I have exactly the same issue, and removing redeploying static files does not solve the problem Commented Jul 6, 2017 at 8:08
  • @Stephen could you tell me which recent modules have you installed ? as i said i have the exact same issue and still didn't find out a solution. Commented Jul 8, 2017 at 14:23

2 Answers 2

2

You have changed "Stores -> Configuration -> Advanced -> Developer -> JavaScript Settings -> Translation Strategy" option to "Embedded (Translation on Admin side)" value. Try to set back default system value "Dictionary (Translation on Storefront side)", js errors will disappear. Regards

0

Recently I had this happen, to fix it I did the following:

I had written 6 custom modules, was running into a variety of these errors and wasn't sure when I had actually made the error happen.

All of my generated javascript assets were missing a closing ')'. The closing ')' of the define() wrapper.

I disabled all of my modules via command line 'bin/magento module:disable modulename' and it was still doing it. The error only stopped after I disabled all modules and ran 'bin/magento setup:static-content:deploy -f'. I'm running in developer mode, so you have to force it with '-f'.

I then enabled modules until the error returned. This gave me which module was causing the problem.

Upon reviewing that modules code, I found a line in my modulename/etc/adminhtml/system.xml was wrong. My <resource>ModuleName::config</resource> was defined from another module that I had copied over.

After fixing this and re-forcing the static-content deploy the issue resolved.

I suspect that it is a definition somewhere in your module's .xml configuration files. Be sure to check that all of your definition values are correct.

Hopefully this helps resolve the issue.

1
  • I ran into this again after deleting a di.xml file from a module. I was able to resolve it by 'bin/magento setup:static-content:deploy -f' again. Developer mode in magento 2 is supposed to generate these automatically... perhaps it is- but it doesn't seem to remove them automatically. Commented Jan 22, 2018 at 17:26

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.