npm run dev启动项目的时候报错
WARNING in ./node_modules/moment/min/moment-with-locales.js 2159:16-50
Module not found: Error: Can't resolve './locale' in '/Users/cm/Desktop/workSpace/superset/superset-frontend/node_modules/moment/min'
点击到./node_modules/moment/min/moment-with-locales.js 2159:16-50位置,发现如图所示:
./代表当前目录,但是当前目录没有locale,具体文件夹如图
发现是路径错误,应该为../locale
于是在webpack.config.js的plugins中修改配置
new webpack.ContextReplacementPlugin(/^\.\/locale$/, context => {
if (!/\/moment\//.test(context.context)) {
return;
}
// context needs to be modified in place
Object.assign(context, {
// include only CJK
regExp: /^\.\/(ja|ko|zh)/,
// point to the locale data folder relative to moment's src/lib/locale
request: '../locale',
});
}),
再次npm run dev成功!