nice-select2 icon indicating copy to clipboard operation
nice-select2 copied to clipboard

npm installs wrong version 2.1.0

Open StenPelzer opened this issue 2 years ago • 8 comments

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

StenPelzer avatar Jul 05 '23 09:07 StenPelzer

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)

brendanheyu avatar Jul 21 '23 02:07 brendanheyu

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

StenPelzer avatar Jul 25 '23 15:07 StenPelzer

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?

erip2 avatar Jul 31 '23 11:07 erip2

@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",

StenPelzer avatar Jul 31 '23 12:07 StenPelzer

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 ?

erip2 avatar Aug 04 '23 08:08 erip2

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

SubbiahMariappan avatar Aug 07 '23 12:08 SubbiahMariappan

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.

StenPelzer avatar Sep 26 '23 15:09 StenPelzer

is it fixed with version 2.2.0?

Tsjippy avatar Apr 16 '24 08:04 Tsjippy