peerDepdencies of a used package not considered
See original GitHub issueBug Description
A package that’s only in peerDependencies
of a used package is still marked as unused even though it really is used.
Code snippets
Where the dependency is used:
const jsdomGlobal = require('jsdom-global');
Where the dependency is listed in package.json:
{
"name": "test_depcheck",
"license": "PUBLIC DOMAIN",
"dependencies": {
"jsdom": "~11.11.0",
"jsdom-global": "~3.0.2"
}
}
Versions
node -v
: v10.15.2npm -v
: 6.4.1depcheck --version
: 0.7.2
Extra info
If you remove jsdom
from package.json
, then yarn install
gives the following error and the code doesn’t work:
yarn install v1.13.0
warning package.json: License should be a valid SPDX license expression
warning test_depcheck: License should be a valid SPDX license expression
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
warning " > jsdom-global@3.0.2" has unmet peer dependency "jsdom@>=10.0.0".
[4/4] 🔨 Building fresh packages...
success Saved lockfile.
✨ Done in 0.70s.
json output:
{"dependencies":[],"devDependencies":[],"missing":{},"using":{"jsdom-global":["/Users/dlj/temp/index.js"],"jsdom":["/Users/dlj/temp/index.js"]},"invalidFiles":{},"invalidDirs":{}}
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Understanding Peer Dependencies in JavaScript
Peer dependencies really come into play when you're developing code that will be used by others, such as plugins and packages.
Read more >Should I duplicate "peerDependencies" in "dependencies ...
So while installing packages using npm install , NPM will attempt to install an optional dependency too. But if it isn't able to...
Read more >npm Peer Dependencies - JavaScript inDepth
Peer Dependencies are used to specify that our package is compatible with a specific version of an npm package. Good examples are Angular...
Read more >npm Peer Dependencies - Fathom
Peer Dependencies. If you've used nodejs at all, you will have come across normal dependencies in package.json. They are used to describe the...
Read more >Difference between dependencies, devDependencies and ...
peerDependencies are not automatically installed. You need to manually modify your package.json file in order to add a Peer Dependency.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@robross0606 could you open a new issue and provide a repository reproducing this error please?
This still appears to be a problem. My project has a peer dependency on
prom-client
:However,
depcheck
lists it as unused after installation: