badgateway/react-ketting

"Failed to resolve entry for package 'react-ketting'" when using vite to build a react app

AlexZeitler opened this issue · 2 comments

I tried to add react-ketting to my react app which is build using vite.

When running yarn dev on (Node 14.9.0), I get this error:

[vite:dep-scan] Failed to resolve entry for package "react-ketting". 
The package may have incorrect main/module/exports specified in its package.json.

I followed the instructions at https://github.com/badgateway/ketting/wiki/React.

I've created a repro here: https://github.com/AlexZeitler/vite-react-ketting-repro

I've started a discussion about the issue on the vite Discord channel and I got this answer:

according to it's package.json, it should have a build version aimed at bundlers ("browser" field) at /browser/react-ketting.min.js, but that folder/file doesn't exist in the bundle. the "main" field does point to a correct CJS module at dist/index.js, but I guess vite wants to prefer the entry defined in the "browser" field, and that one not existing throws it off.

evert commented

This was probably left there when I copied package.json from ketting, which does have its own browser builds. I think the solution is to just remove the browser property.

Thanks, seems to work fine!