Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BN from Elliptic included twice by browserify #1923

Closed
Ayms opened this issue Sep 2, 2019 · 8 comments
Closed

BN from Elliptic included twice by browserify #1923

Ayms opened this issue Sep 2, 2019 · 8 comments
Labels

Comments

@Ayms
Copy link

Ayms commented Sep 2, 2019

First congratulations for browserify, I tried it some years ago and a very few was working, now it's working very well

This is a small issue here so you can close it if you like, see indutny/bn.js#227 , while browserifying https://github.com/Ayms/bitcoin-transactions (see the code in html dir and README in browserify)

The BN code from Elliptic module is included twice by browserify, it does not look like an issue at bitcoin-transactions or elliptic side finally, but not sure, please let me know you thoughts

@goto-bus-stop
Copy link
Member

Usually that means that there are two different versions of that module in your tree. npm ls bn.js will show a list. You can try npm dedupe to get a single version but that'll only work if they are semver compatible.

@Ayms
Copy link
Author

Ayms commented Sep 2, 2019

@fanatid looks like it's on elliptic side (did install the latest version to be sure, the one available via npm):

find . -name bn.js on elliptic node_modules

./node_modules/bn.js
./node_modules/bn.js/lib/bn.js

Strangely npm ls bn.js ran on elliptic says [email protected]

And on bitcoin-transactions or anything including elliptic in node_modules:

[email protected] extraneous

npm ERR! extraneous: [email protected] /blabla/bitcoin-transactions/node_modules/elliptic/node_modules/bn.js

@goto-bus-stop
Copy link
Member

goto-bus-stop commented Sep 2, 2019

Hmm, that looks like a problem in your install tree. Did you maybe go into the node_modules/elliptic folder and run npm install there at some point? It's fine and will work, but it does cause things like these extraeneous dependency installations.

Either way, it would be fixed by removing the node_modules folder and doing npm install it your project folder again. The 'did you turn it off and on again' of npm :D

@Ayms
Copy link
Author

Ayms commented Sep 2, 2019

For me it's a problem in the elliptic install tree, because I just reinstalled it elsewhere to be sure, @fanatid continuing this on elliptic issue

Off the record, I have to say, I really hate npm, maybe I will love it one day when this thing will work correctly

Thanks for the answers @goto-bus-stop

@goto-bus-stop
Copy link
Member

goto-bus-stop commented Sep 2, 2019

I really don't think there's anything wrong with elliptic. Your npm ls output is flagging one of the bn.js installations as extraneous, which strongly indicates that the problem is with that installation, not with any particular package. Possibly the tree was changed outside of npm's knowledge.

Make sure you're using a recent version of npm (use npm install -g npm to update). Did you try deleting your entire node_modules and rerunning npm install?

@Ayms
Copy link
Author

Ayms commented Sep 2, 2019

Yes, you were probably right, see indutny/elliptic#190 (comment)

I don't remember how I installed elliptic first, maybe an old version of npm or just an unzip of master at that time, reinstalling with current npm does not produce the same result (elliptic node_modules are included in the root node_modules)

Still, I don't get very well what npm has to do with this and browserify, and why the current install duplicates bn, I will not change it since it saves a little in fact and I prefer to have each package completely separated

Maybe take a little look at the node_modules/elliptic dir in bitcoin-transactions if you can see what causes the problem (not for me but that might happen for other projects, maybe browserify could detect and correct it)

@goto-bus-stop
Copy link
Member

goto-bus-stop commented Sep 7, 2019 via email

@Ayms
Copy link
Author

Ayms commented Sep 9, 2019

The good reason I have is to keep the modules separated, I usually install via npm then copy the modules in node_modules, therefore there is usually other subsequent node_modules dirs in the tree

One might say that this is the old way but I prefer to do it like this and deduplicate/clean myself if needed, so I don't have a mess in node_modules with everything mixed and 1% used (and for the very reason that you give, ie some identical files can have some slight differences), additionnaly it happens often that I have to modify said modules and usually don't really care of the updates for those modules

Now I don't understand very well why in my specific case BN is duplicated twice, probably it desserves some investigations (indeed everything looks fine in elliptic and if I remove the call to BN for bitcoin-transactions, BN is still duplicated)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants