I am using a few Kontent packages in a project that is using Vite as the build tool. When I run vite build I receive errors like Failed to resolve entry for package "@kentico/kontent-delivery". The package may have incorrect main/module/exports specified in its package.json..
If I look at the entries in package.json and compare to the package in node_modules it does seem to be an issue of incorrect paths being specified as, for example, package.json defines the module path as ./dist/esm5/index.js, but there is no such path under dist.
This incorrect paths issue also seems to be the case in:
Not sure if there are others - these are the ones I happen to be using. If this is an issue that requires fixing, should I raise the same issue in each of those repositories?
There should be no "incorrect main/module/exports" error in the build and the build should succeed.
I have changed the paths in the package.json of my local node_modules, for example, set "module": "./dist/esnext/index.js" (as that path does exist) and can confirm this fixes the build error.
Test environment
Platform/OS: Windows, TypeScript 4.5.5, Vite 2.8.4, Node 14.18.1
Brief bug description
I am using a few Kontent packages in a project that is using Vite as the build tool. When I run
vite build
I receive errors likeFailed to resolve entry for package "@kentico/kontent-delivery". The package may have incorrect main/module/exports specified in its package.json.
.If I look at the entries in package.json and compare to the package in
node_modules
it does seem to be an issue of incorrect paths being specified as, for example,package.json
defines themodule
path as./dist/esm5/index.js
, but there is no such path underdist
.This incorrect paths issue also seems to be the case in:
Not sure if there are others - these are the ones I happen to be using. If this is an issue that requires fixing, should I raise the same issue in each of those repositories?
Repro steps
npm run build
in the terminalExpected behavior
There should be no "incorrect main/module/exports" error in the build and the build should succeed.
I have changed the paths in the
package.json
of my localnode_modules
, for example, set"module": "./dist/esnext/index.js"
(as that path does exist) and can confirm this fixes the build error.Test environment
Screenshots