Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error because npm promote ajv-keywords #170

Closed
Val-istar-Guo opened this issue Apr 28, 2021 · 4 comments
Closed

Error because npm promote ajv-keywords #170

Val-istar-Guo opened this issue Apr 28, 2021 · 4 comments

Comments

@Val-istar-Guo
Copy link

Val-istar-Guo commented Apr 28, 2021

Run npm list ajv ajv-keywords in my project:

├─┬ eslint@7.25.0
│ ├─┬ @eslint/eslintrc@0.4.0
│ │ └── ajv@6.12.6 
│ ├── ajv@6.12.6 
│ └─┬ table@6.6.0
│   └── ajv@8.2.0 
└─┬ mili@3.10.2
  ├── UNMET PEER DEPENDENCY ajv@8.2.0 
  ├── ajv-keywords@5.0.0 
  └─┬ npm@6.14.13
    └─┬ request@2.88.0
      └─┬ har-validator@5.1.5
        └── ajv@6.12.6 

My project don't depend on ajv, But the dependencies of my project depend on ajv and ajv-keywords. ajv-keyword was promote to ./node_modules/ajv-keyworkds because it isn't conflict, but ajv not.....

However the actual installation effect is:

├── ajv-keywords@5.0.0 
├─┬ eslint@7.25.0
│ ├─┬ @eslint/eslintrc@0.4.0
│ │ └── ajv@6.12.6 
│ ├── ajv@6.12.6 
│ └─┬ table@6.6.0
│   └── ajv@8.2.0 
└─┬ mili@3.10.2
  ├── UNMET PEER DEPENDENCY ajv@8.2.0 
  
  └─┬ npm@6.14.13
    └─┬ request@2.88.0
      └─┬ har-validator@5.1.5
        └── ajv@6.12.6 

And mili Throw Error:

Cannot find module 'ajv/dist/compile/codegen'
Require stack:
- ....../node_modules/ajv-keywords/dist/definitions/typeof.js
- ....../node_modules/ajv-keywords/dist/keywords/typeof.js

peerDependencies is not easy to use。。。

@medikoo
Copy link

medikoo commented Jan 11, 2022

I can confirm, that any installation with npm v6 of project that has:

  • dependency that depends on ajv v8, ajv-keywords v5
  • eslint (which depends on ajv v6)

Is getting broken, because npm installs ajv v6 and ajv-keywords v5 top level

@Val-istar-Guo
Copy link
Author

I can confirm, that any installation with npm v6 of project that has:

  • dependency that depends on ajv v8, ajv-keywords v5
  • eslint (which depends on ajv v6)

Is getting broken, because npm installs ajv v6 and ajv-keywords v5 top level

I understand the reason for the error, but there is no way to solve this problem elegantly.
I have to run npm install ajv@8 in my project.
Even if my project doesn't require ajv8 directly.

@medikoo
Copy link

medikoo commented Jan 11, 2022

I understand the reason for the error, but there is no way to solve this problem elegantly.

This is a bug on the npm v6 side (see: npm/npm#19877) AFAIK it can be fixed simply by upgrading to npm v7 or later (default starting from Node.js v16). Otherwise, there's no reliable fix, assuming the current design of ajv-keywords

It could be worked around in ajv-keywords if similarly as ajv-format it'll drop peer dependency on AJV, so providing it with ajv instance would be good enough (cc @epoberezkin ).

In serverless we're considering hard-coding what we need from ajv-keywords (and it's just regex) into our package to workaround that until npm v6 is EOL

@Val-istar-Guo
Copy link
Author

Thank you for your help. I guess my best solution is to wait for npm7 to be supported in my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants