Search code examples
javascriptnode.jslocalemomentjscreate-react-app

Create-React-App with Moment JS: Cannot find module "./locale"


Just ran an npm update on my web application and now Moment JS appears to be failing with the following message:

Error: Cannot find module "./locale"
\node_modules\moment\src\lib\moment\prototype.js:1
> 1 | import { Moment } from './constructor';

Not sure what version of Moment JS I had prior to my update, but my application has been working for months.

I created another react app and ran an npm install moment --save and modified the source to display the time and ended up with the same error described above.

Not sure if there is a fail-proof way to integrate Moment JS using Create-React-App currently short of ejecting to manage the webpack settings myself, but I really don't want to do this. Anyone else seeing these issues or having success? If so, a short write up would go along way to helping out.


Solution

  • Appears this has already been identified as an issue for Moment JS version 2.19. If you have upgraded to 2.19 run npm install [email protected] to revert back to previous version until it is fixed!

    See thread: https://github.com/moment/moment/issues/4216