jbmusso / gremlin-javascript

JavaScript tools for graph processing in Node.js and the browser inspired by the Apache TinkerPop API
MIT License
214 stars 63 forks source link

Module not found: Error: Cannot resolve module 'tls' in... #76

Closed danvoyce closed 7 years ago

danvoyce commented 7 years ago

I've ran the basic installation, but as soon as I import Gremlin

import { createClient } from 'gremlin';

I get the following errors:

ERROR in ./~/ws/lib/WebSocketServer.js
Module not found: Error: Cannot resolve module 'tls' in
...

and

ERROR in ./~/options/lib/options.js
Module not found: Error: Cannot resolve module 'fs' in
...

Am running it with webpack and the latest stable version of Node (7.4). Have also tried it with version 5.9, but still get same issue.

Any ideas?

dragma commented 7 years ago

Is your code ran client side ?

danvoyce commented 7 years ago

yep :) It says this works in Modern Browsers?

jbmusso commented 7 years ago

Thanks for sharing this. Can you try with v2.3.2 please? npm install gremlin@2.3.2 should do the trick (feel free to rm -rf node_modules/gremlin prior just to be sure). I published v2.3.2 a few days ago with a new version of ws so maybe this introduced backward compatibility breaking changes when using this library in the browser like the one you're mentioning here.

As @dragma pointed out, the issue is most likely related to the fact that your code is running in a browser. How do you bundle your code? Do you use Webpack or Browserify, or something else?

fs does not exist in the client since it's a Node.js core used for interacting with the filesystem. Some web bundler shim these dependencies, and it could require a bit of tuning to have gremlin-javascript work in the browser depending on how you bundle your front end code.

danvoyce commented 7 years ago

That did the trick! I was for a minute wondering if this was for server side only, based on those errors.

And yes, using Webpack.

Thanks!