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

The answer above, though I have no doubt works for some, does not work for me. The solution I found is fairly quick and easy, but is a little more complicated than simple downgrading.

This problem originates as a result of and can be fixed with webpack. So we're going to have to add a few lines of code to our webpack.config.js file. If you don't have one yet, you can add one to the root webpack directory:

YOURAPPNAME/node-modules/webpack/

So now that you're inside your webpack.config.js file, you need to add a few lines of code. Just copy and paste this inside the new file or adapt it to the code you already have in webpack.config.js.

module.exports = {
    resolve: {
        alias: {
            moment$: 'moment/moment.js'
        }
    }
};

Your import statement of moment in your index.js (or otherwise named) file should look like this:

import moment from 'moment'

You should now be able to use moment completely normally. For example:

var tomorrow = moment().add(1, "day")

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


Application built with Create React App and using Moment 2.24.0, the following seems to be working fine:

import moment from 'moment';
import 'moment/min/locales';

Instead of importing moment-with-locales directly. Alternatively, also possible to only import required locales:

import moment from 'moment';
import 'moment/locale/fr';
import 'moment/locale/ru';