SIGSEGV on a require with UPPERcase letters in path

Hello,

the moment.js library with bundled locales is crashing on the Android build but not on local preview on windows. Please take a look on the attached example.

The solution I found was to use always lowercase locale strings, such as:

moment.locale('pt-BR'); -> Android: crash | Local: OK
moment.locale('pt-br'); -> Android: OK | Local: OK

On debugging I found out that the crash occurs on the line 1817 of the moment-with-locales.js file, which is a require on a folder that doesn’t exists, that should be an obvious error if it were to crash all the times.

Excerpt from the moment.js source

function loadLocale(name) {
    var oldLocale = null;
    // TODO: Find a better way to register and load all the locales in Node
    if (!locales[name] && (typeof module !== 'undefined') &&
            module && module.exports) {
        try {
            oldLocale = globalLocale._abbr;
            require('./locale/' + name); // <- crash here!!!
            // because defineLocale currently also sets the global locale, we
            // want to undo that for lazy loaded locales
            getSetGlobalLocale(oldLocale);
        } catch (e) { }
    }
    return locales[name];
}

Thanks for posting Uldis! reCAPTCHA wasn’t friendly with me today :frowning:

@Igor: thanks for reporting and taking the time to debug this. I have now logged a ticket for this.