moment.tz() fails when I use it in ES6/react?
UPD for 2018 (ES6/React), this works when using npm version of moment-tz
import moment from 'moment-timezone';
moment.tz(moment.tz.guess()).zoneAbbr();
The main
field of the package.json
of the moment-timezone
library points to the index.js
file which is a CommonJS module.
It will work as expected if you require the module at the top of your file:
require('moment-timezone');