marmelab/react-admin

[SOLVED] Build issues with Vite when react-admin was installed by pnpm

Closed this issue · 0 comments

When trying to build a react-admin 5.x project (didnt try older versions) installed with pnpm, I would get this error:

[vite]: Rollup failed to resolve import "ra-core" from "/workspace/cockpit/projects/bo/node_modules/react-admin/dist/esm/index.js

After a lot of trial and error and researching this issue, it turns out the solution is to create a
.npmrc file
and to add this line:
shamefully-hoist=true

Then run pnpm install, and then building with vite works without any issue.