Vite: 使用第三包时报错,not provide an export named 'default'

Created on 28 Aug 2020  ·  2Comments  ·  Source: vitejs/vite

比如使用mockjs等npm包时,由于打包后的文件是commonjs的,会出现如下错误
Uncaught SyntaxError: The requested module '/@modules/mockjs/src/mock.js' does not provide an export named 'default'
有没有好的解决方法

pending triage

All 2 comments

The best way is to file an issue to mockjs asking for providing ESM builds. For the general support, please track on #720.

You also can used
optimizeDeps inside vite.config.js by bundle it to es module(doc is here https://github.com/vitejs/vite/blob/master/src/node/config.ts#L96)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

duanxianze picture duanxianze  ·  3Comments

Dykam picture Dykam  ·  4Comments

shen-zhao picture shen-zhao  ·  3Comments

wobsoriano picture wobsoriano  ·  4Comments

jakobrosenberg picture jakobrosenberg  ·  3Comments