Closed mamadfar closed 5 months 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
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.
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
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?
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'); /**
schema
to be an object or boolean');
}
if (!options) {
options = {};
}
// This section indexes subschemas in the provided schema, so they don't need to be added with Validator#addSchema
// This will work so long as the function at uri.resolve() will resolve a relative URI to a relative URI
var id = schema.$id || schema.id;
var base = urilib.resolve(options.base||anonymousBase, id||'');Hi @awwright any updates on this issue?
The above PR should address this issue.
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 ?