bluzky / nice-select2

A lightweight vanilla javascript library that replaces native select elements with customizable dropdowns
https://bluzky.github.io/nice-select2/
MIT License
361 stars 60 forks source link

Can't import the library because of wrong "main" entry in package.json #70

Closed CapsE closed 5 months ago

CapsE commented 11 months ago

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.

kodie commented 11 months ago

Fixed https://github.com/bluzky/nice-select2/commit/964cbee17fecc22c9ebc86ad3795abe8b04cf47d

remderk commented 8 months ago

The problem persists when installing via npm

jamesfawcett commented 7 months ago

This issue is still in the latest release 2.1.0 in both this Github repo releases, and npm @CapsE

bdube30 commented 6 months ago

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.

dougblackjr commented 6 months ago

For all looking, while we wait for this to be updated in NPM, here's how I solved this on my end:

  1. Install patch-package: npm i patch-package. There are a few other steps here, found this great article.
  2. In node_modules/nice-select2/package.json, apply the changes in the commit above
  3. Run npx patch-package nice-select2 --exclude 'nothing'
  4. Run npm install
  5. Save your changes to git if so inclined.
Tsjippy commented 5 months ago

fixed in version 2.2.0