Skip to content

v1 driver cannot resolve internal modules #396

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

Closed
Ethan-Arrowood opened this issue Jul 16, 2018 · 9 comments
Closed

v1 driver cannot resolve internal modules #396

Ethan-Arrowood opened this issue Jul 16, 2018 · 9 comments

Comments

@Ethan-Arrowood
Copy link

Ethan-Arrowood commented Jul 16, 2018

Installed most recent stable version of neo4j-driver today and when I try to launch my app I get the following error message: Module not found: Can't resolve 'dns' in '/app/node_modules/neo4j-driver/lib/v1/internal' (due note I'm using create-react-app and running the command npm run start)

I'll look into this issue and see if its just a bad publish or something else. Other recommendations would be helpful though.

@Ethan-Arrowood
Copy link
Author

Ahh this is not meant to run in the browser (see for more details facebook/create-react-app#3543)

@lutovich
Copy link
Contributor

Hi @Ethan-Arrowood,

It is possible to use this driver in both browser and NodeJS environments. Modules like dns or tls do exist only in Node but driver tries to detect their presence at runtime and fallback to browser alternatives. Here is an example of the dns feature detection: link.

Maybe this error has something to do with how modules are resolved by infrastructure created by create-react-app. I'll reopen this issue to investigate. Please feel free to update this issue if you have more details or steps to reproduce to share.

@lutovich lutovich reopened this Jul 16, 2018
@Lynne-Daniels
Copy link

Lynne-Daniels commented Jul 29, 2018

Newbie here -- I'm just going to share my experience since a google search on Can't resolve 'dns' in '/app/node_modules/neo4j-driver/lib/v1/internal brought me right here. My copy-paste attempt to use the 'Hello World' example at https://neo4j.com/docs/developer-manual/current/drivers/get-started/ failed with the same error. Here are the changes that made it all work:

const uri = 'bolt://localhost';
const neo4jDriver = require('neo4j-driver');
const driver = neo4jDriver.v1.driver(uri, neo4jDriver.v1.auth.basic('someuser', 'somepass'));```

Also had to create a user/password and give the user roles in the dashboard application.

@p1zz4br0etch3n
Copy link

I also faced the problem using create-react-app and neo4j-driver@1.6.2. For me using require didn't solve the problem. But I found a workaround:
include the static web build (neo4j-web.min.js) in your index.html. Follow the docs about public folder to do so and global variables to access it.
I hope that helps.

@jeroenVerdonschot
Copy link

jeroenVerdonschot commented Sep 18, 2018

Hi Guys,

Other newbie here. I have the same problem when testing in StackBlitz.
@p1zz4br0etch3n would you be so kind to explain a bit more.

Thanks!

Sorry found it I should use:
var driver = neo4j.v1.driver("bolt://localhost", neo4j.v1.auth.basic("neo4j", "neo4j"));

@p1zz4br0etch3n
Copy link

Using window.neo4j.v1 ... is even better cause then it is obvious that you're using a global variable intentionally and your eslint doesn't warn you.

@lutovich
Copy link
Contributor

Dear All,

Module resolution errors seem to be caused by runtime feature detection in the driver. It contains Node and browser environment specific components in one codebase which confuses bundlers. They can't determine that Node components are unused and obviously fail at compile time when trying to resolve required Node APIs.

Probably the best workaround right now is to include neo4j-web.min.js in index.js as suggested by @p1zz4br0etch3n here.

Mentioned PR should fix the problem and make it possible to use driver with a simple import or require. It will hopefylly go in 1.7 branch and be released in 1.7.0-beta02 available via npm install --save neo4j-driver@next pre-release channel.

@lutovich
Copy link
Contributor

Hello,

Pre-release 1.7.0-beta02 version of the driver with the fix is now released. It can be installed using npm install --save neo4j-driver@next. Please give it a try and let us know if there are any problems with it and Webpack. Thanks!

@p1zz4br0etch3n
Copy link

Yep, now it works!
Thank you very much!

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

No branches or pull requests

5 participants