vite 报错 does not provide an export named ‘default‘

2022-12-06 13:50:55 浏览数 (1)

版本

vite 3.2.3

现象

项目依赖B B依赖A 运行时引用A报错

The requested module ‘/node_modules/A/lib/index.js?v=8bb229e7’ does not provide an export named ‘default’

原因

依赖A不是ES模块

解决

vite.config.ts添加配置

代码语言:javascript复制
export default defineConfig({
	...
    optimizeDeps: {
        include: ['A']
    }
})

0 人点赞