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

npm installs wrong version 2.1.0 #60

Open StenPelzer opened 1 year ago

StenPelzer commented 1 year ago

Hi,

When installing the npm package (2.1.0), the install still has the old package.json file from before https://github.com/bluzky/nice-select2/commit/964cbee17fecc22c9ebc86ad3795abe8b04cf47d.

The installed version still shows "main": "src/js/nice-select2.js".

Sten

brendanheyu commented 1 year ago

Just out of interest - did you manage to get around this and have it work in your project? If so, how?

EDIT:: So, yup - just modify the package.json or rename the js to /src/js/nice-select2.js (so simple I'm embarrassed)

StenPelzer commented 1 year ago

Yes that's it. Until this issue is resolved, be aware that you have to change it again after doing an npm update.

erip2 commented 1 year ago

EDIT:: So, yup - just modify the package.json or rename the js to /src/js/nice-select2.js (so simple I'm embarrassed)

Can you please explain what needs to be done exactly?

StenPelzer commented 1 year ago

@erip2 In node_modules/nice-select2/package.json on line 5 edit: "main": "src/js/nice-select.js", to "main": "src/js/nice-select2.js",

erip2 commented 1 year ago

Sorry, it's still not clear for me.

Isn't it already like this: https://github.com/bluzky/nice-select2/blob/master/package.json#L5 ?

SubbiahMariappan commented 1 year ago

Sorry, it's still not clear for me.

Isn't it already like this: https://github.com/bluzky/nice-select2/blob/master/package.json#L5 ?

Yes, but after installing in your project if you check inside node_modules folder the package.json has the wrong path in main attribute. till this issue resolves you have to include the scripts in your index.html or move the js and css files inside your project src so that it wont throw error when moving to higher environments

StenPelzer commented 12 months ago

For anyone coming across this nowadays, this has still not been fixed. But, if you're using yarn you can save yourself some time and frustration by setting up an afterInstall script.

First, run this command to add the afterInstall plugin to (if found it here): yarn plugin import https://raw.githubusercontent.com/mhassan1/yarn-plugin-after-install/v0.3.1/bundles/@yarnpkg/plugin-after-install.js

Then add an afterInstall script in .yarnrc.yml: afterInstall: sed -i -e 's/nice-select.js/nice-select2.js/g' node_modules/nice-select2/package.json && rm -f node_modules/nice-select2/package.json-e

This command creates a temporary file in which it writes the contents of the nice-select2's package.json, but replacing the incorrect text. Then it removes the temporary file.

Tsjippy commented 5 months ago

is it fixed with version 2.2.0?