-
[HMR] bundle has 1 warningsclient.js?f33d:189 ./node_modules/moment/src/lib/locale/locales.jsModule not found: Error: Can't resolve './locale' in '/.../node_modules/moment/src/lib/locale'Frontend/react 2020. 1. 7. 13:09
Error:
[HMR] bundle has 1 warningsclient.js?f33d:189 ./node_modules/moment/src/lib/locale/locales.jsModule not found: Error: Can't resolve './locale' in '/.../node_modules/moment/src/lib/locale'
Solution:
npm install --save moment
npm install --save-dev moment-locales-webpack-plugin
// webpack.config.js const MomentLocalesPlugin = require('moment-locales-webpack-plugin'); module.exports = { plugins: [ // // To strip all locales except “en” // new MomentLocalesPlugin(), // Or: To strip all locales except “en”, “es-us” and “ru” // (“en” is built into Moment and can’t be removed) new MomentLocalesPlugin({ localesToKeep: ['es-us', 'ru'], }), ], };
// node_modules/moment/src/lib/locale/locales.js function loadLocale(name) { var oldLocale = null; // TODO: Find a better way to register and load all the locales in Node if (!locales[name] && (typeof module !== 'undefined') && module && module.exports) { try { oldLocale = globalLocale._abbr; var aliasedRequire = require; aliasedRequire('./locale/' + name); getSetGlobalLocale(oldLocale); } catch (e) {} } return locales[name];
To
// node_modules/moment/src/lib/locale/locales.js function loadLocale(name) { var oldLocale = null; // TODO: Find a better way to register and load all the locales in Node if (!locales[name] && (typeof module !== 'undefined') && module && module.exports) { try { oldLocale = globalLocale._abbr; var aliasedRequire = require; aliasedRequire('moment/locale/' + name); getSetGlobalLocale(oldLocale); } catch (e) {} } return locales[name];
'Frontend > react' 카테고리의 다른 글