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.

Error: Cannot find module 'ajv/lib/refs/json-schema-draft-06.json'

See original GitHub issue

Looks like the latest release (8.0.4) no longer contains the lib folder.

https://github.com/ajv-validator/ajv/commit/c4de1a4628757527a579ad179adf29c462acad1b#r49028541

Error: Cannot find module 'ajv/lib/refs/json-schema-draft-06.json'
Require stack:
- /home/runner/work/cspell/cspell/packages/cspell-types/node_modules/ajv-cli/dist/commands/ajv.js
- /home/runner/work/cspell/cspell/packages/cspell-types/node_modules/ajv-cli/dist/commands/compile.js
- /home/runner/work/cspell/cspell/packages/cspell-types/node_modules/ajv-cli/dist/commands/index.js
- /home/runner/work/cspell/cspell/packages/cspell-types/node_modules/ajv-cli/dist/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/runner/work/cspell/cspell/packages/cspell-types/node_modules/ajv-cli/dist/commands/ajv.js:10:26)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/runner/work/cspell/cspell/packages/cspell-types/node_modules/ajv-cli/dist/commands/ajv.js',
    '/home/runner/work/cspell/cspell/packages/cspell-types/node_modules/ajv-cli/dist/commands/compile.js',
    '/home/runner/work/cspell/cspell/packages/cspell-types/node_modules/ajv-cli/dist/commands/index.js',
    '/home/runner/work/cspell/cspell/packages/cspell-types/node_modules/ajv-cli/dist/index.js'
  ]
}

What version of Ajv are you using? Does the issue happen if you use the latest version?

Ajv options object


JSON Schema


Sample data


Your code


Validation result, data AFTER validation, error messages


What results did you expect?

Are you going to resolve the issue?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
epoberezkincommented, Apr 2, 2021

right… I am reverting it. Best to leave it till v9

1reaction
Jason3Scommented, Apr 2, 2021

@epoberezkin,

Thank you for the quick reply. I’m using ajv-cli with nothing special.

Here is the ajv-cli/ajv.ts line with the issue:

// ajv.ts
// ...
import {getOptions} from "./options"
import * as util from "./util"
import * as path from "path"
import * as draft6metaSchema from "ajv/lib/refs/json-schema-draft-06.json"

type AjvMethod = "addSchema" | "addMetaSchema"

Read more comments on GitHub >

github_iconTop Results From Across the Web

require a json file results in an error: Cannot find module
I had a similar problem when trying to import json from a file in a typescript project. I used
Read more >
Issues - GitHub
Error : Cannot find module './types.json' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) ...
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
Why the "Error: cannot find module" Occurs. This error occurs because of the following reasons: you're trying to import an item from a ......
Read more >
[Solution] Error: Cannot Find Module "nodemailer" - Courier
js project that creates an empty package.json file. Afterward, install the nodemailer library using the command shown below. 1 ...
Read more >
Error: Cannot find module in JavaScript [SOLVED]
We can solve Error: Cannot find module by installing the missing module. ... folder holding the package.json file and execute the above command...
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