nice-select2
nice-select2 copied to clipboard
Can't import the library because of wrong "main" entry in package.json
Hi, you have an error in your package.json
{
"name": "nice-select2",
"version": "2.1.0",
"description": "A lightweight Vanilla JavaScript plugin that replaces native select elements with customizable dropdowns.",
"main": "src/js/nice-select.js",
"directories": {
"doc": "docs"
}
...
You're pointing to src/js/nice-select.js but the file is acutally named nice-select2.js this leads to issue when I try to import the library using webpack.
Fixed https://github.com/bluzky/nice-select2/commit/964cbee17fecc22c9ebc86ad3795abe8b04cf47d
The problem persists when installing via npm
This issue is still in the latest release 2.1.0 in both this Github repo releases, and npm @CapsE
Anyone know if there a way to fix this ? I use vitejs and I got this error : "Failed to resolve entry for package "nice-select2". The package may have incorrect main/module/exports specified in its package.json."
I'm pretty sure it the same kind of issue,
I would really like to use nice-select2 for my project.
Thanks.
For all looking, while we wait for this to be updated in NPM, here's how I solved this on my end:
- Install patch-package:
npm i patch-package. There are a few other steps here, found this great article. - In
node_modules/nice-select2/package.json, apply the changes in the commit above - Run
npx patch-package nice-select2 --exclude 'nothing' - Run
npm install - Save your changes to git if so inclined.
fixed in version 2.2.0