-
-
Notifications
You must be signed in to change notification settings - Fork 330
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Prerequisites
- I'm using the latest version
- I've read the relevant documentation
- I've searched for existing issues
- I've checked the list of known issues
- I've read the issue reproduction guide
Reproduction url
https://gitlab.com/aarongoldenthal/aarongoldenthal (sorry, not a minimal reproduction, but the issue and fix is below)
Reproduction access
- I've made sure the reproduction is publicly accessible
Description of the issue
In some cases, running knip on an eleventy project fails with the following error (this is the Alpine Linux output, but occurs on Win 11 as well)
$ knip
file:///usr/local/lib/node_modules/knip/dist/plugins/eleventy/index.js:19
const templateFormats = localConfig.templateFormats || defaultEleventyConfig.templateFormats;
^
TypeError: Cannot read properties of undefined (reading 'templateFormats')
at Object.resolveConfig (file:///usr/local/lib/node_modules/knip/dist/plugins/eleventy/index.js:19:41)
at async runPlugin (file:///usr/local/lib/node_modules/knip/dist/WorkspaceWorker.js:276:40)
at async WorkspaceWorker.runPlugins (file:///usr/local/lib/node_modules/knip/dist/WorkspaceWorker.js:319:13)
at async build (file:///usr/local/lib/node_modules/knip/dist/graph/build.js:94:35)
at async main (file:///usr/local/lib/node_modules/knip/dist/index.js:[43](https://gitlab.com/aarongoldenthal/aarongoldenthal/-/jobs/10184307712#L43):88)
at async run (file:///usr/local/lib/node_modules/knip/dist/cli.js:26:111)
at async file:///usr/local/lib/node_modules/knip/dist/cli.js:111:1
Node.js v22.16.0The issue is in line
| const templateFormats = localConfig.templateFormats || defaultEleventyConfig.templateFormats; |
localConfig is undefined, and this line is the one that doesn't handle that.
The following change resolved the issue.
- const templateFormats = localConfig.templateFormats || defaultEleventyConfig.templateFormats;
+ const templateFormats = localConfig?.templateFormats || defaultEleventyConfig.templateFormats;Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working