moment: Getting webpack error after update to 2.19.0

Don’t know if it is related to #4216 because I’m using Angular 4.4.4 and that is a React issue, so I’m posting this as a separate issue.

I got the following error after the update:

__WEBPACK_IMPORTED_MODULE_2_moment__ is not a function

I’m using the following moment packages

"moment": "2.19.0",
"@types/moment": "2.13.0",   

The code where I get the error is quite simple:

import * as moment from 'moment';
...

  if (moment().year() !== this.mainData.activeYear)

...

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 45
  • Comments: 23 (3 by maintainers)

Most upvoted comments

Same here. Not using Angular or React. This is my webpack error:

WARNING in ./~/moment/src/lib/locale/locales.js
Module not found: Error: Can't resolve './locale' in '/data/jenkins/workspace/project/node_modules/moment/src/lib/locale'
./~/moment/src/lib/locale/locales.js 65:16-60
./~/moment/src/lib/locale/locale.js
./~/moment/src/moment.js
./script.js

+1 - Same issue with Angular 4

This version ( 2.19.0 must be fixed ) for the ‘moment’ ahahah, install the 2.18.1 “moment”: “~2.18.1”

react webpack error

WARNING in ./node_modules/moment/src/lib/locale/locales.js
Module not found: Error: Can't resolve './locale' in 'blahblahblah/node_modules/moment/src/lib/locale'
 @ ./node_modules/moment/src/lib/locale/locales.js 65:16-60
 @ ./node_modules/moment/src/lib/locale/locale.js
 @ ./node_modules/moment/src/moment.js
 @ ./src/client/components/ArticlesGrid/index.js
 @ ./src/client/containers/StuffPage/index.js
 @ ./src/client/routes.jsx
 @ ./src/client/index.js
 @ multi (webpack)-dev-server/client?http://0.0.0.0:8050 webpack/hot/dev-server babel-polyfill ./src/client/index.js

Same issue here 😢 We’ll downgrade back to 2.18 until this is resolved.

same problem when moment upgrade to version 2.19.0 WARNING in ./~/_moment@2.19.0@moment/src/lib/locale/locales.js Module not found: Error: Can't resolve './locale' in '/Users/XXX/code/gitlab/web-editor/node_modules/moment@2.19.0@moment/src/lib/locale' @ ./~/_moment@2.19.0@moment/src/lib/locale/locales.js 65:16-60 @ ./~/_moment@2.19.0@moment/src/lib/locale/locale.js @ ./~/_moment@2.19.0@moment/src/moment.js @ ./~/_antd@2.9.2@antd/lib/calendar/index.js @ ./~/_antd@2.9.2@antd/lib/index.js @ dll lib

Same problem with vuejs and webpack.

Downgraded to ~2.18.0 which circumvents this for the time being.