Reputation: 279
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?
Upvotes: 15
Views: 38139
Reputation: 148
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
Upvotes: 1
Reputation: 340
I addressed this problem by deleting the node_modules
directory and the package-lock.json
file, followed by rerunning the npm install
command.
Upvotes: -2
Reputation: 279
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"
Upvotes: 12
Reputation: 7
I had the same problem for me it was to delete de node_module and reinstall all the packages again. It works for me.
Upvotes: -5