I've been using numeraljs for component development and I've been testing with LockerService on today and I'm getting the following error:

Uncaught TypeError: Cannot read property 'numeral' of undefined throws at /resource/XXXXXXXXXXXXX/numeraljs/numeral.js:855:46

Now even with this error the page is working fine. It is just annoying to have errors on the page and not know how to fix them. The app is hosted in a VisualForce page using Lightning Out:

<apex:includeLightning />

$Lightning.use("c:myApp", function() {

In my component I import the script with Lightning require from a static resource:

<ltng:require scripts="{!$Resource.numeraljs + '/numeral.js'}" />

I'm fairly sure it has something to do with window, SecureWindow, and the way numeraljs is initiated

  • 1
    Having trouble reproducing this. Are you using the latest version of numeral.js? Does the error happen on load or while using the app? – TrevorBliss Jan 5 '17 at 2:37
  • I'm using the latest numeraljs and it does indeed happen on load. There error doesn't show up in console it shows up at the bottom of the page in the footer area. – WarbleSync Jan 5 '17 at 14:10
  • Here's a screen cap of the error and where it appears: imgur.com/a/h0fvn – WarbleSync Jan 5 '17 at 14:18
  • 1
    Just double checked my version ... looks like 2.1.4 is the latest and that doesn't produce the error! Happy camper! Thanks for the help Trevor Bliss – WarbleSync Jan 5 '17 at 14:32
  • Awesome! I'd recommend putting that as the answer and accepting it to help out others. – TrevorBliss Jan 5 '17 at 17:20

For future searchers.. as @WawrbleSync points out, the latest version of Numeral.js (2.0.4) is LockerService compliant and loads fine with LockerService enabled.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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