Description:
This repo shows a problem with how [email protected] hoists dependencies while ignoring peer dependencies (--legacy-peer-deps) during npm install
I am using following devDependencies ::
"babel-loader": "9.1.2",
"eslint": "8.36.0"
- [email protected] 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
While installing I am ignoring peer dependencies (--legacy-peer-deps), [email protected]
still gets hoisted on the root level of node_modules and is using incorrect version of [email protected].
This gives following error on build:
Error: Cannot find module 'ajv/dist/compile/codegen'
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
Steps to reproduce
- git clone https://github.com/developer-73/ajv-peerdep-issue.git
- npm install --legacy-peer-deps
- Verify node_modules, tree structure should be like:
|__@eslint
|[email protected] <<<<<---- |
|[email protected] >>---| Incompatible with [email protected]
|[email protected]
|[email protected]
Note: This issue is only reproducible when ignoring peer dependencies i.e. (npm install --legacy-peer-deps) and not with (npm install). With npm install it gives correct tree structure
|__@eslint
|[email protected]
|[email protected] <<<<<---- |
|[email protected] >>---| Compatible with [email protected]
|[email protected]