Closed BMFreed closed 1 month ago
The issue is that baseUrl
isn't set in either of the tsconfig.json
files.
For now you can do this:
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json",
"compilerOptions": {
"baseUrl": ".nuxt"
}
}
Or wait until the next release of Knip, this will have a patch to handle it for you.
The issue is that
baseUrl
isn't set in either of thetsconfig.json
files.For now you can do this:
{ // https://nuxt.com/docs/guide/concepts/typescript "extends": "./.nuxt/tsconfig.json", "compilerOptions": { "baseUrl": ".nuxt" } }
Or wait until the next release of Knip, this will have a patch to handle it for you.
It worked! Thank you so much!
:rocket: This issue has been resolved in v5.27.1. See Release 5.27.1 for release notes.
Using Knip in a commercial project? Please consider becoming a sponsor.
Unfortunately, there is another issue regarding Nuxt. If Vue isn't listed in dependencies or devDependencies - knip doesn't seem to enable the Vue plugin. In the reproduction URL I tried to enable the Vue plugin manually within knip.json by setting "vue" to true and to the default (as mentioned here) config value, but this doesn't work.
Can this be fixed without needing to add vue to dependencies or devDependencies?
Thanks in advance!
Can this be fixed without needing to add vue to dependencies or devDependencies?
Like you said, you can enable the Vue plugin manually. You can use --debug
to see whether the plugin is enabled or not, and what it finds. I'd need a reproduction to look into it (please file a new issue then).
Reproduction url
https://codesandbox.io/p/devbox/priceless-aryabhata-zl8s4x?file=%2Fapp.vue%3A8%2C8
Description of the issue
Knip doesn't seem to be working correctly in Nuxt projects. Here is an example when we import a function in app.vue:
And that same function is then reported by Knip as an unused file, while the import is unresolved:
For some reason, Knip doesn't resolve Nuxt paths properly.
Running
pnpm knip --tsConfig .nuxt/tsconfig.json
or copying thetsconfig.json
from.nuxt
folder into the main folder does not fix the issue.