tdegrunt / jsonschema

JSON Schema validation
Other
1.82k stars 262 forks source link

Cannot find module 'url' #367

Closed mamadfar closed 5 months ago

mamadfar commented 2 years ago

After I deploy my project ( react => v17 ), when I try to move that page which I used jsonschema, I get this error "Cannot find module 'url'". For fixed this I had to install url package manually in the project. But this is a temporary way. Can you fix this ?

geotom commented 2 years ago

Same here: Had to add "url" to my packages, and then in the code where i use it I had to import as well before calling the validation (import * as url from "url"). Otherwise the validation throws an error that urilib.resolve is not a method

AlexPernot commented 1 year ago

Same, it seems the lib was designed with only Node in mind. If you are in the browser, you will need to install "url" from npm to have the url.resolve function. I don't know why it broke recently, I guess "url" was installed by another dependency.

gugurete commented 1 year ago

Yes, tdegrunt/jsonschema has an implicit dependency on the "url" library. It would be nice to make this explicit or even better ditch it altogether to have a nice, lean, no external dependencies jsonschema validator

awwright commented 1 year ago

The "url" package should be builtin. It is not supposed to refer to a third-party package. Can you tell me a little more about your environment?

gugurete commented 1 year ago

Environment: Browser (vuejs, vite).

The uri library is only present in nodejs, the browser does not have it, the jsonschema package.json should explicitely specify this library var urilib = require('url');

validator.js:118 Uncaught (in promise) TypeError: urilib.resolve is not a function at Validator2.validate (validator.js:118:21) at module.exports.validate (index.js:14:12) at Proxy.validate (edit.vue:81:39)

...

var urilib = require('url'); /**

smeng9 commented 1 year ago

Hi @awwright any updates on this issue?

tdegrunt commented 5 months ago

The above PR should address this issue.