depcheck: Depcheck started returning incorrect unused dependencies without any changes
Bug Description
I’m not sure it’s related, but since of today depcheck started reporting incorrect unused dependencies.
Versions
node -v
: 14.16.1npm -v
: 6.14.12depcheck --version
: 1.4.2
Extra info
We are using npx depcheck
and until yesterday it worked in our CI, starting from today it stopped working.
We didn’t change anything, and on the same commit, it worked yesterday it stopped working today.
I tried to figure out what’s wrong so I ran the depcheck locally on my laptop and it worked.
I then looked at the depcheck
installed globally on my laptop and saw it’s from July.
At this point the depcheck version is 1.4.2
Running npx depcheck
resulted in this output:
$ npx depcheck --config=./ci/.depcheckrc
No depcheck issue
After that I reinstalled it globally using:
$ npm install -g depcheck
C:\Users\Slavas\AppData\Roaming\npm\depcheck -> C:\Users\Slavas\AppData\Roaming\npm\node_modules\depcheck\bin\depcheck.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\depcheck\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
The depcheck version didn’t change and remained 1.4.2
Now running the check command fails:
$ npx depcheck --config=./ci/.depcheckrc
Unused dependencies
* aws-sdk
* express
Unused devDependencies
* @types/chai
* @types/kafkajs
* chai
* chai-as-promised
* http-status-codes
* kafkajs
My assumption is when running npx
is that it used the cached version that was on my laptop and after reinstalling it, it downloaded a new version and stopped working.
The thing I don’t understand is that depcheck -v
returned 1.4.2
both while the behaviour changed.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 15
- Comments: 24 (13 by maintainers)
Commits related to this issue
- Switch back to official depcheck@1.4.3 Ref: https://github.com/depcheck/depcheck/issues/687#issuecomment-1008355947 — committed to upleveled/preflight by karlhorky 2 years ago
- Switch back to official depcheck@1.4.3 Ref: https://github.com/depcheck/depcheck/issues/687#issuecomment-1008355947 — committed to gruvector/preflight by karlhorky 2 years ago
It’s not just you,
@babel/parser
version 7.16.5 broke it, released 12 hours ago Workaround, is to lock it using yarn resolutionsI just released version 1.4.3
For this exact solution you need to use
yarn
and havedepcheck
as your dependency. I’m not aware of any manual dependency locking mechanism fornpx
. Fornpm
npm-force-resolutions might work, but I haven’t tried it personally