问题
再本地搭建superset开发环境的时候,启动superset服务npm run dev-server的时候报了这样一个错误 Module not found: Error: Can't resolve './locale' in '/superset/superset-frontend/node_modules/moment/min'。

如何解决:
点击到nodemoudle依赖里面里面,第2160行的代码是关于报错的位置,如下图:

发现./下面没locale,而是在外层,是路径错误,应该为../locale,那么怎么去修改路径呢?
当然你可以直接修改依赖库源码,改为../locale即可解决,但是不建议这么做,不然无法线上自动化打包部署,建议去修改webpack配置,在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-server

报错消失,YYDS!
今天就总结到这里啦! 后续会不定时更新哦,欢迎在评论区交流。
如果文章对你有所帮助,❤️关注+点赞❤️鼓励一下!
往期回顾
vue3.x使用prerender-spa-plugin预渲染达到SEO优化
vue3.x使用prerender-spa-plugin预渲染达到SEO优化




6379

被折叠的 条评论
为什么被折叠?



