moment-precise-range icon indicating copy to clipboard operation
moment-precise-range copied to clipboard

Cannot set properties of undefined (setting 'preciseDiff')

Open fh32000 opened this issue 2 years ago • 3 comments
trafficstars

    "moment": "^2.29.4",
    "moment-precise-range-plugin": "^1.3.0",
     "vue": "^3.2.36",

import * as moment from 'moment'; import 'moment-precise-range-plugin';

var days = moment("2014-01-01 12:00:00").preciseDiff("2015-03-04 16:05:06")

fh32000 avatar Dec 01 '22 16:12 fh32000

@codebox @chrisj-skinner

fh32000 avatar Dec 01 '22 16:12 fh32000

I'm not able to reproduce this problem, if you can post some runnable code and include details of the node.js version you are using I can investigate further

codebox avatar Dec 01 '22 22:12 codebox

I'm using Vite to build front-end and had the same problem. Workaround is to copy and modify plugin file: change closure to named function momentPreciseRangePlugin and add line:

export default momentPreciseRangePlugin;

And were you're using momentum with plugin it should be:

import moment from "moment";
import momentPreciseRangePlugin from "./components/moment-precise-range";
momentPreciseRangePlugin(moment);

coffebar avatar Mar 16 '23 09:03 coffebar