When running vite, I receive the following error:
15:52:07 [vite] Internal server error: Failed to resolve entry for package ... The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "notistack5". The package may have incorrect main/module/exports specified in its package.json.
How can I resolve it?
I found the solution, the problem was in the package.json file of the notistack5 module. The module file did not exist - ie the correct file name was:
"module": "dist/notistack.esm.js"
instead of the following (this file didn't exist):
"module": "dist/notistack5.esm.js"
I was able to resolve this by following a few steps:
1.0) In package.json, define main, module, and types
"main": "dist/index.js",
"module": "dist/package-name.esm.js",
"types": "dist/types/types.d.ts",
2.0) In the tsconfig.json, narrow down where the type declarations will live
"declaration": true,
"declarationDir": "./dist/types",
3.0) Ensure dependencies needed in your package are in the dependencies object in package.json, and not devDependencies
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With