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

runtime error when updating from 5.1.1 to 5.2.2 #570

Closed
Zamiell opened this issue Mar 22, 2024 · 5 comments
Closed

runtime error when updating from 5.1.1 to 5.2.2 #570

Zamiell opened this issue Mar 22, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Zamiell
Copy link
Contributor

Zamiell commented Mar 22, 2024

I updated my monorepo with this commit: IsaacScript/isaacscript@b727ffa

Here is the corresponding CI run:
https://github.com/IsaacScript/isaacscript/actions/runs/8392460435/job/22985155348

Knip throws the following runtime error:

Analyzing workspace ....
node:internal/modules/cjs/loader:1144
  const err = new Error(message);
              ^

Error: Cannot find module 'D:/Repositories/isaacscript/configs/base-eslint'
Require stack:
- D:\Repositories\isaacscript\index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Function.resolve (node:internal/modules/helpers:187:19)
    at Function._resolve [as resolve] (D:\Repositories\isaacscript\node_modules\jiti\dist\jiti.js:1:251148)
    at resolve (file:///D:/Repositories/isaacscript/node_modules/knip/dist/util/require.js:13:48)
    at getDependenciesDeep (file:///D:/Repositories/isaacscript/node_modules/knip/dist/plugins/eslint/helpers.js:28:50)
    at getDependenciesDeep (file:///D:/Repositories/isaacscript/node_modules/knip/dist/plugins/eslint/helpers.js:31:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.resolveConfig (file:///D:/Repositories/isaacscript/node_modules/knip/dist/plugins/eslint/index.js:12:26)
    at async WorkspaceWorker.findDependenciesByPlugins (file:///D:/Repositories/isaacscript/node_modules/knip/dist/WorkspaceWorker.js:202:54)
    at async main (file:///D:/Repositories/isaacscript/node_modules/knip/dist/index.js:146:108) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'D:\\Repositories\\isaacscript\\index.js' ]
}

I believe this is a regression, since the run-time error did not occur in version 5.1.1.

@Zamiell Zamiell added the bug Something isn't working label Mar 22, 2024
@webpro
Copy link
Collaborator

webpro commented Mar 22, 2024

Unfortunately from the error message alone I can't deduct the problem. Please create a minimal reproduction of the issue so I can look into it.

@peplin
Copy link

peplin commented May 3, 2024

Here's a small repository with a minimal reproduction: https://github.com/peplin/knip-issue570-repro

This issues seems to be related to running dependency resolution on the nested .eslintrc.js file. That extends an .eslintrc.js from the top of the workspace, which extends from the root. When knip runs dependency resolution, it seems to be looking for an .eslintrc.js in an intermediate directory where there is none.

I removed the offending .eslintrc.js file to confirm this is the problem, and the error does go away. However, it appears in another (non-eslint) file that uses a relative import, so I think there's a general issue with how dependencies are being resolved in newer versions of knip.

@webpro webpro closed this as completed in 20e44c6 May 3, 2024
@webpro
Copy link
Collaborator

webpro commented May 3, 2024

🚀 This issue has been resolved in v5.12.1. See Release 5.12.1 for release notes.

Using Knip in a commercial project? Please consider sponsoring me.

@webpro
Copy link
Collaborator

webpro commented May 3, 2024

Thanks @peplin, super helpful! Just what we needed.

@peplin
Copy link

peplin commented May 3, 2024

Thanks! I can confirm this is fixed for us in 5.12.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants