ajv-validator / ajv-validator/ajv-keywords
Error: Cannot find module 'ajv/dist/compile/codegen'
- Langage dominant
- TypeScript
- Étoiles
- 257
- Forks
- 51
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
I am facing this build error in "ajv-keywords" after installing packages with `npm install --legacy-peer-deps`
**Error: Cannot find module 'ajv/dist/compile/codegen'**
**Background**:
Consider the following dependency trees:
```
|__@eslint
|__avj@6.12.6 <<<<<---- |
|__ajv-keywords@5.1.0 >>---^ Incompatible with ajv@6.12.6
|__schema-utils@4.0.0
|___ajv@8.12.0
```
```
|__@eslint
|__avj@6.12.6
|__ajv@8.12.0 <<<<<---- |
|__ajv-keywords@5.1.0 >>---^ Compatible with ajv@8.12.0
|__schema-utils@4.0.0
```
Notice: with `npm install --legacy-peer-deps` (1st tree) gives incorrect tree structure and not with `npm install` (2nd one).
`npm install --legacy-peer-deps` results in following error on `npm run build`:
**Error: Cannot find module 'ajv/dist/compile/codegen'**
I have prepared a repo at https://github.com/developer-73/ajv-peerdep-issue.
I am using following devDependencies ::
"babel-loader": "9.1.2",
"eslint": "8.36.0"
- eslint@8.36.0 depends on avj@^6.12.4
- babel-loader@^9.1.2 depends on schema-utils@^4.0.0 which further depends on :
ajv@^8.8.0 and ajv-keywords@^5.0.0, where ajv-keywords has a peer dependency on ajv@^8.8.0
Run `npm install --legacy-peer-deps` and notice the incorrect tree structure in node_modules i.e. ajv-keywords@5.1.0
gets hoisted on the root level of node_modules and is using incorrect version of ajv@6.12.6.
This is a problem because the hoisted ajv-keywords@^5.0.0 will not have its peer dependency on ajv@^8.8.0 met.
Note: This works correctly on npm < 7
`Possible solution: Can you please add "ajv" as your packages dependencies instead of devDependency? This will ensure "ajv-keywords" to get latest "ajv" version`
```
**Environment**
npm: 8.19.4
Node.js: 18.15.0
OS Name: Mac OS
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.