Open AvioLT opened 3 months ago
So not sure what's tripping up the Nx daemon here. Knip does not use or interfere with it.
When you do npm run knip
then Knip executes config files like jest.config.js
or vite.config.ts
. But Nx itself has only JSON config files. And without --fix
or --cache
Knip only reads, never writes.
Hello,
I've encountered the same issue with my nx repo (v18), i've upgraded to v19 to check if it would solve the issue : it didn't. I've tried to add knip to both, a new nx project and an old project i had lying around under nx v16 : There was no issue.
I've dug a bit more and ran yarn run knip --debug
:
[ 'nx' ]
[.] Glob options
{
patterns: [ 'jest.config.{js,ts,mjs,cjs,json}', 'package.json' ],
cwd: '/home/MyUser/work/MyProject',
dir: '/home/MyUser/work/MyProject',
gitignore: false,
absolute: true
}
[.] Jest config file paths (1)
[ '/home/MyUser/work/MyProject/jest.config.ts' ]
NX Daemon process terminated and closed the connection
So i've tried to delete the jest.config.ts
, and now knip is running correctly.
For context, here is the content of the file :
import { getJestProjectsAsync } from '@nx/jest';
export default async () => ({
projects: await getJestProjectsAsync(),
});
What I tried next was to prevent Knip from scanning this file using negated pattern, but with no success. At this point i'm unsure of why this file is scanned. Maybe it's the nx plugin ?
In any case the workaround for now is to use knip --production
to avoid this file.
@webpro I'm available if you want more info just lmk, thanks for this great tool :heart_hands:
You can try to disable the Jest plugin by setting jest: false
in the Knip config. Or exclude that Jest config file e.g. with an empty array "jest": { "config": [] }
This work but it's still a work around. Why does Knip analyzing this file runs the Nx daemon ?
Any interesting output perhaps when using --debug
?
Reproduction url
https://nx.dev/getting-started/tutorials/angular-monorepo-tutorial
Description of the issue
So, I was trying to build up a config slowly to match my NX monorepo structure. I wanted to do this by making a plain new NX project and adding knip to it. However, it fails.
So starting from https://nx.dev/getting-started/tutorials/angular-monorepo-tutorial I get a plain repo with some basic config (Angular, Jest, Cypress, Webpack, ...)
This gives me a project with the following versions
Then run the basic commands of
npm init @knip/config
&npm run knip
and run into the following issue.Here is the daemon.log
At which point I'm lost, not sure why the connection is being closed prematurely or something? Maybe somebody with more NX experience can shed some light on it.