You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Force use of unmanaged ajv-cli version as required
The ajv-cli command line tool is used for validating data files against their JSON schema.
In general, it is preferable, and for some schemas even mandatory, to use the modern versions of ajv-cli. However,
support for the "Draft 4" schema specification was dropped in ajv-cli version 4.0.0. So when working with JSON schemas
that specify that draft, it is necessary to use ajv-cli 3.3.0, the last compatible version.
This means that some projects may have dependencies on multiple versions of ajv-cli. This package is distributed via the
npm registry. Unfortunately, npm does not have support for managing multiple versions of a binary dependency.
npm's "alias" feature seems ideal:
https://docs.npmjs.com/cli/v8/commands/npm-install
> npm install <alias>@npm:<name>:
> Install a package under a custom alias. Allows multiple versions of a same-name package side-by-side
However, this is only suitable for code dependencies. There is no special handling of providing access via npx to the
binary of the aliased package.
So the only reasonable option is to manage only one of the two tool versions. This should be a simple matter of
specifying the version of the package in the commands using the unmanaged tool: `npx [email protected]`:
https://docs.npmjs.com/cli/v8/commands/npx#description
> Package names with a specifier will only be considered a match if they have the exact same name and version as the
> local dependency.
Unfortunately, a bug in npm causes the version specifier to be ignored when the managed version is already installed.
This bug is reportedly fixed, but the fix is not in a Node.js release yet, and even after that it may take us quite some
time to upgrade to the version of Node.js which contains the fix.
The workaround implemented here is to run the unmanaged tool command from outside the project folder.
0 commit comments