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

Unable to resolve module url from node_modules/ajv/lib/compile/resolve.js #435

Closed
pavlelekic opened this issue Mar 10, 2017 · 11 comments
Closed

Comments

@pavlelekic
Copy link

simulator screen shot mar 10 2017 15 46 54
I tried using Ajv in a React Native app, however I wasn't even able to include the module (see the screenshot). I tried the stable version, as well as 5.0.3-beta, same thing happens. I used the code example in the docs:

var Ajv = require('ajv');
var ajv = new Ajv(); // options can be passed, e.g. {allErrors: true}
var validate = ajv.compile(schema);
var valid = validate(data);
if (!valid) console.log(validate.errors);

But like the error says, I wasn't able to validate anything, it was failing even before with the require('ajv') statement.

@epoberezkin
Copy link
Member

epoberezkin commented Mar 10, 2017

It says something about "url" module not found. It is a core node.js module that would also be available if you were to use browserify.

It also mentions facebook/react-native#4968

@epoberezkin
Copy link
Member

As a workaround I can suggest using supplied bundle - it exports global Ajv.

@pavlelekic
Copy link
Author

Thanks!

@epoberezkin
Copy link
Member

@claudiorodriguez do you know how to solve it?

@nenti
Copy link

nenti commented Mar 11, 2017

I have the same issue. Unable to resolve module 'url'.
var url = require('url');
Seems as if core nodejs modules are not available in react-native and not related to this module.

@epoberezkin
Copy link
Member

epoberezkin commented Mar 11, 2017

@nenti @pavlelekic I think including url module from npm as your app dependency can help. Please let me know if it does or doesn't.

@superandrew213
Copy link

@epoberezkin I can confirm that adding url as a dependency works.

@epoberezkin
Copy link
Member

@superandrew213 thank you

@jsaucedo
Copy link

How do you add url as dependency of your React Native project?

@superandrew213
Copy link

@jsaucedo npm i --save url

@ropering
Copy link

ropering commented Feb 7, 2022

yarn add url

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

No branches or pull requests

6 participants