Skip to content

Conversation

dlively1
Copy link

I didn't see any contributor documentation but wanted to open this PR in case it helps anyone else.

Thanks for creating this tool its exactly what I was looking for!

When I attempted to use it I was getting the following error.

ConfigError: [BABEL] unknown file: Preset /* your preset */ requires a filename to be set when babel is called directly,

babel.transformSync(code, { filename: 'file.ts', presets: [/* your preset */] });

See https://babeljs.io/docs/en/options#filename for more information.
    at transformSync (/Users/dan/.nvm/versions/node/v18.19.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/transform.js:42:76)
    at fromJavaScript (/Users/dan/.nvm/versions/node/v18.19.0/lib/node_modules/code-complexity/dist/src/lib/complexity/strategies/cyclomatic.js:26:50)
    at calculate (/Users/dan/.nvm/versions/node/v18.19.0/lib/node_modules/code-complexity/dist/src/lib/complexity/strategies/cyclomatic.js:17:20)
    at Complexity.computeComplexity (/Users/dan/.nvm/versions/node/v18.19.0/lib/node_modules/code-complexity/dist/src/lib/complexity/complexity.js:28:59)
    at Complexity.compute (/Users/dan/.nvm/versions/node/v18.19.0/lib/node_modules/code-complexity/dist/src/lib/complexity/complexity.js:13:45)
    at /Users/dan/.nvm/versions/node/v18.19.0/lib/node_modules/code-complexity/dist/src/lib/complexity/complexities.js:10:98
    at Array.map (<anonymous>)
    at Complexities.computeFor (/Users/dan/.nvm/versions/node/v18.19.0/lib/node_modules/code-complexity/dist/src/lib/complexity/complexities.js:10:54)
    at Statistics.compute (/Users/dan/.nvm/versions/node/v18.19.0/lib/node_modules/code-complexity/dist/src/lib/statistics/statistics.js:16:59)
    at main (/Users/dan/.nvm/versions/node/v18.19.0/lib/node_modules/code-complexity/dist/src/io/index.js:13:44)

I didn't see any other bug reports so perhaps this is a misconfiguration within my project. Let me know if that might be the case

Version info from my project

Node: v18.19.0
"@babel/core": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"@babel/preset-typescript": "^7.23.2",
"typescript": "^4.7.4",

@simonrenoult simonrenoult force-pushed the main branch 2 times, most recently from c9ed4e4 to 59f5c5a Compare August 21, 2025 22:31
@simonrenoult
Copy link
Owner

It should no longer be needed with v5, could you tell me if it solves your issue?

You can grab it like this: npx code-complexity@alpha <path> [options]

@simonrenoult simonrenoult added bug Something isn't working next-release Fix or feature will be available in the very next version release. labels Aug 21, 2025
@simonrenoult simonrenoult force-pushed the main branch 2 times, most recently from 4e99801 to 6244a98 Compare August 22, 2025 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next-release Fix or feature will be available in the very next version release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants