node-binary-search-tree icon indicating copy to clipboard operation
node-binary-search-tree copied to clipboard

Util dependency not specified in package.json

Open vitorsgomes opened this issue 7 years ago • 9 comments

In the file lib/avltree.js there is a require for util, but this lib was never specified as a dependency in package.json.

When trying to use node-binary-search-tree on a project that don't have util as a dependency it's generate an error.

vitorsgomes avatar Mar 08 '17 04:03 vitorsgomes

How do you have a project that doesn't have util as a dependency?

amaramth avatar Mar 27 '17 14:03 amaramth

I have a similar problem in a react native project, when including binary tree it complains about being unable to resolve util in avltree.js, understood this is native node, but how could this happen?

Alttaf avatar May 26 '17 23:05 Alttaf

this could be from the above https://github.com/facebook/react-native/issues/526, seems like it is a react native issue you have to npm install util as a workaround

Alttaf avatar May 26 '17 23:05 Alttaf

@Alttaf, Yes, that solution works!

dinithminura avatar Jun 23 '17 07:06 dinithminura

I suppose you miss a util dependency in your package.json... Please add it...

marcolino avatar Aug 24 '17 16:08 marcolino

@marcolino util is built in

amaramth avatar Aug 24 '17 22:08 amaramth

What do you mean by builtin? If I do not add it to my project dependencies, I can't build my project, which has node-binary-search-tree as a sub-sub-sub dependency... :-(

marcolino avatar Aug 25 '17 09:08 marcolino

@alice0meta means that util is a core Node.js module. Project dependencies are external userland modules from NPM.

This is strictly an incompatibility with React Native not fully supporting a Node.js-compatible environment, and it is going to be extremely common among many Node modules you try to require unless they have been browserify-ed (or intentionally made compatible with React Native) since depending on such core modules like util (for inherits, usually) or events (for EventEmitter) is extremely common.

JamesMGreene avatar Aug 27 '17 15:08 JamesMGreene

I have made a pull request that simply copies the inherits method from node.js utils to customUtils, so there is no longer a dependency on the node module. The correct way of doing this is to upgrade to ES6 as inherits is deprecated anyway, but this is simple and fast... https://github.com/louischatriot/node-binary-search-tree/pull/17 (useful if you don't want/need the utils package - as mentioned by @Alttaf)

deive avatar Sep 26 '17 13:09 deive