Compiler warning "Module not found: Error: Can't resolve './locale'" since I use momentjs in my react app

17,988

This is a bug in Moment v2.19, due to changes in require: Issue on Github

You can lock out 2.18.1 version in your package.json or apply fixes, mentioned in the link.

Share:
17,988
gfjr
Author by

gfjr

Updated on July 26, 2022

Comments

  • gfjr
    gfjr almost 2 years

    I get the following warning since I use moment.js in my application (npm 5.4.2, react 15.4, typescript 2.5.3, webpack 2.2.1, webpack-dev-server 2.4.1).

    In ./src/utils/commons.ts I use momentjs and it's working fine, but I get the warning.

    Any help appreciated.

    WARNING in ./~/moment/src/lib/locale/locales.js
    Module not found: Error: Can't resolve './locale' in 'C:\myproject\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
     @ ./src/utils/commons.ts
     @ ./src/components/Login.tsx
     @ ./src/app.tsx
     @ ./src/index.tsx
     @ multi (webpack)-dev-server/client?http://localhost:3000 webpack/hot/dev-server react-hot-loader/patch webpack-dev-server/client?http://localhost:3000 webpack/hot/only-dev-server ./src/index.tsx
    webpack: Compiled with warnings.
    
  • gfjr
    gfjr over 6 years
    Works perfect, thank you. :o)