question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v1.9.0 @cfworker/json-schema/dist/validator.js - Error when importing

See original GitHub issue

The following code in validator.js:

export class Validator {
    schema;
    draft;
    shortCircuit;
    lookup;
    constructor(schema, draft = '2019-09', shortCircuit = true) {
        this.schema = schema;
        this.draft = draft;
        this.shortCircuit = shortCircuit;
        this.lookup = dereference(schema);
    // rest of code
    }

causes a loader error when attempting to import { Validator } from '@cfworker/json-schema'. It appears JS does not understand schema, draft, shortCircuit, lookup public instance fields appearing before constructor. Issue is fixed after removing.

Working validator.js code:

export class Validator {
     constructor(schema, draft = '2019-09', shortCircuit = true) {
        this.schema = schema;
        this.draft = draft;
        this.shortCircuit = shortCircuit;
        this.lookup = dereference(schema);
    // rest of code
    }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
stoneroll6commented, Nov 20, 2021

@jdanyow Updated to 1.10.1, and it works like a charm. Thank you!

1reaction
stoneroll6commented, Nov 14, 2021

The error appeared while attempting to publish a Worker via Wrangler from a local machine. I had installed @cfworker/json-schema locally via npm (v6.14.14)

edit: Also would like to say thanks to everyone who contributed to these packages. I was struggling with Ajv for a bit until I found this.

WebPack Error: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
| import { dereference } from './dereference.js';
| import { validate } from './validate.js';
| export class Validator {
>    schema;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error [ERR_MODULE_NOT_FOUND]: Cannot find module
This just worked for me, referencing my TS-extensioned exporting files as JS, where imported. The more I learn about JavaScript/TypeScript/Node, ...
Read more >
Get syntax error when importing into a React app #690 - GitHub
Description tl;dr: Here's a recording of the issue - https://recordit.co/hzEhqOLC1X I am using Next, React and Model Viewer to try and make ...
Read more >
import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are ...
Read more >
Resolve "Unable to import module" errors from Python ... - AWS
I receive an "Unable to import module" error when I try to run my AWS Lambda code in Python. How do I resolve...
Read more >
GUS Import Issues (Technical Bulletin) - GovDelivery
regarding the import error messages. A very common message received is: “MISMO XML Contents do not pass the MISMO & Extension Schema Validation”...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found