Skip to content

Conversation

@bh2smith
Copy link
Contributor

@bh2smith bh2smith commented Feb 6, 2025

Users of this package keep running into the following import issue: This forces users to include ajv-draft-04 into their project dependencies even if they are not directly using it. This PR proposes moving the import statement into the only code block where it is actually required and thus (hopefully) avoiding the error. Its a bit surprising that the dependencies don't force the package to be there. Maybe there is some other problem at play...

node:internal/modules/cjs/loader:1248
  const err = new Error(message);
              ^

Error: Cannot find module 'ajv/dist/core'
Require stack:
- home/project/node_modules/ajv-draft-04/dist/index.js
- home/project/node_modules/@apidevtools/swagger-parser/lib/validators/schema.js
- home/project/node_modules/@apidevtools/swagger-parser/lib/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object.<anonymous> (home/project/node_modules/ajv-draft-04/dist/index.js:4:16)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'home/project/node_modules/ajv-draft-04/dist/index.js',
    'home/project/node_modules/@apidevtools/swagger-parser/lib/validators/schema.js',
    'home/project/node_modules/@apidevtools/swagger-parser/lib/index.js'
  ]
}

bh2smith added a commit to BitteProtocol/make-agent that referenced this pull request Feb 6, 2025
There seems to be some unusual import error that end users get without
this package. I have proposed a potential solution in the dependency
repo: APIDevTools/swagger-parser#268

In the meantime, we just put this back here.
@philsturgeon philsturgeon enabled auto-merge (squash) February 11, 2025 13:55
@philsturgeon philsturgeon merged commit ff79822 into APIDevTools:main Feb 11, 2025
5 checks passed
@github-actions
Copy link

github-actions bot commented Jun 3, 2025

🎉 This PR is included in version 11.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bh2smith bh2smith deleted the import-error branch June 4, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants