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?
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?
Share Improve this question edited Jun 7, 2023 at 13:47 mikemaccana 123k110 gold badges427 silver badges531 bronze badges asked Mar 5, 2022 at 16:06 edem adzavonedem adzavon 2791 gold badge2 silver badges6 bronze badges 1- I had malformed package version string of a dependency. When I removed all versions and installed with valid version string 0.2.6, this error has gone. – Eugene Gr. Philippov Commented Jun 9, 2024 at 5:55
4 Answers
Reset to default 12I 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
I addressed this problem by deleting the node_modules
directory and the package-lock.json
file, followed by rerunning the npm install
mand.
I had the same problem for me it was to delete de node_module and reinstall all the packages again. It works for me.