Record an unexpected bug.
Recommonded: Quick Understanding of main, module, exports, and type:module in package.json
This error means that the entry file of the package, such as "index.js", cannot be found, which is defined by the main
and module
properties of package.json
.
But I went in the wrong direction at the beginning. My project is a monorepo
, using pnpm workspace, and recently used the "workspace:xxx" protocol of pnpm. So I suspect that vite does not recognize the workspace protocol and cannot find the package. I tried to upgrade vite, but it didn't work.
What was the final reason? Because I re-cloned the project, the package folder (dist) of the sub-project was gone, so vite could naturally find the library but not the entry file. Just re-execute the build
command.