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.
Application built with Create React App and using Moment 2.24.0, the following seems to be working fine: Instead of importing moment-with-locales directly. Alternatively, also possible to only import required locales:
React components implement a render () method that takes input data and returns what to display. This example uses an XML-like syntax called JSX. Input data that is passed into the component can be accessed by render () via this.props.
This example uses an XML-like syntax called JSX. Input data that is passed into the component can be accessed by render () via this.props. JSX is optional and not required to use React. Try the Babel REPL to see the raw JavaScript code produced by the JSX compilation step.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With