masalibの日記

システム開発、運用と猫の写真ブログです

react-momentがwebpack4.5で動かない問題

reactで時間を使うパッケージでreact-momentというものがるのですが
webpack4.5のバージョンをあげたら動かなくなった

ERROR in ./node_modules/react-moment/dist/index.js
Module not found: Error: Can't resolve 'moment' in 'C:\git\xxxxsystem\node_modules\react-moment\dist'
 @ ./node_modules/react-moment/dist/index.js 1:82-99
 @ ./src/components/App.jsx
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.jsx

無視するプラグインとかいれたしたのですが
解消されませんでした
webpack.config

    new webpack.IgnorePlugin(/\.\/locale$/),
    new webpack.ContextReplacementPlugin(/\.\/locale$/, 'empty-module', false, /js$/)
|<<

結局、たどり着いたのがissuesで・・・

https://github.com/gpbl/react-day-picker/issues/505


>||
npm add moment

# + moment@2.22.0
# added 1 package from 6 contributors in 22.765s

をおこなったら解決した

助かったけど、バージョンアップで意味のわからん所で
エラーになるのは勘弁してほしい

React入門 React・Reduxの導入からサーバサイドレンダリングによるUXの向上まで (NEXT ONE)

React入門 React・Reduxの導入からサーバサイドレンダリングによるUXの向上まで (NEXT ONE)