I am using Vite+React. I am getting error while running npm run dev.
"[ERROR] Could not resolve require("./locale/**/*") node_modules/moment-with-locales-es6/node_modules/moment/min/moment-with-locales.min.js:1:16645: 1 │ ...e&&module&&module.exports)try{b=Bf._abbr,require("./locale/"+a),$a(b)}catch(a){}return Ff[a]}function $a(a,b){v..."
I am using below versions of the packages.
- React: 18.3.1
- Vite: 5.4.1
- moment: 2.30.1
- moment-with-locales-es6: 2.18.1
I also added below code in vite.config.js file.
resolve: {
alias: {`your text`
'moment$': 'moment/min/moment.with-locales.js',
},
},
How to solve this problem?
I tried with multiple versions of Moment.js like 2.18.1, 2.25.2 etc.