bluzky/nice-select2

npm installs wrong version 2.1.0

Opened this issue · 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

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)

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

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 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

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 ?

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

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.

is it fixed with version 2.2.0?