simonrenoult / code-complexity

Measure the churn/complexity ratio. Higher values mean hotspots where refactorings should happen.
MIT License
282 stars 28 forks source link

Error: Cannot find module '@babel/plugin-transform-typescript' #44

Open pahlers opened 2 years ago

pahlers commented 2 years ago

Running npx code-complexity . -cs halstead returns the error Error: Cannot find module '@babel/plugin-transform-typescript'

Error

$ npx code-complexity . -cs halstead
Beware, the 'halstead' and 'cyclomatic' strategies are only available for JavaScript/TypeScript.
Error: Cannot find module '@babel/plugin-transform-typescript'
Require stack:
- /home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/files/plugins.js
- /home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/files/index.js
- /home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/index.js
- /home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/dist/src/lib/complexity/cyclomatic.js
- /home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/dist/src/lib/complexity/index.js
- /home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/dist/src/lib/statistics.js
- /home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/dist/src/lib/index.js
- /home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/dist/src/io/index.js
- /home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/dist/bin/code-complexity.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
    at resolve (node:internal/modules/cjs/helpers:108:19)
    at tryRequireResolve (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/files/plugins.js:128:9)
    at resolveStandardizedNameForRequire (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/files/plugins.js:162:19)
    at sync (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/files/plugins.js:185:12)
    at sync (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/gensync/index.js:182:19)
    at /home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/gensync/index.js:210:24
    at Generator.next (<anonymous>)
    at resolvePlugin (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/files/plugins.js:60:17)
    at resolvePlugin.next (<anonymous>)
    at loadPlugin (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/files/plugins.js:66:27)
    at loadPlugin.next (<anonymous>)
    at createDescriptor (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/config-descriptors.js:148:16)
    at createDescriptor.next (<anonymous>)
    at evaluateSync (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/gensync/index.js:251:28)
    at /home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/gensync/index.js:31:34
    at Array.map (<anonymous>)
    at Function.sync (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/gensync/index.js:31:22)
    at Function.all (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/gensync/index.js:210:24)
    at Generator.next (<anonymous>)
    at createDescriptors (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/config-descriptors.js:109:41)
    at createDescriptors.next (<anonymous>)
    at createPluginDescriptors (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/config-descriptors.js:106:17)
    at createPluginDescriptors.next (<anonymous>)
    at /home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/config-descriptors.js:69:32
    at Generator.next (<anonymous>)
    at Function.<anonymous> (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/gensync-utils/async.js:21:3)
    at Generator.next (<anonymous>)
    at evaluateSync (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/gensync/index.js:251:28)
    at Function.sync (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/gensync/index.js:89:14)
    at sync (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/gensync-utils/async.js:66:25)
    at sync (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/gensync/index.js:182:19)
    at onFirstPause (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/gensync/index.js:210:24)
    at Generator.next (<anonymous>)
    at cachedFunction (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/caching.js:54:46)
    at cachedFunction.next (<anonymous>)
    at mergeChainOpts (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/config-chain.js:357:34)
    at mergeChainOpts.next (<anonymous>)
    at chainWalker (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/config-chain.js:324:14)
    at chainWalker.next (<anonymous>)
    at buildRootChain (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/config-chain.js:58:36)
    at buildRootChain.next (<anonymous>)
    at loadPrivatePartialConfig (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/partial.js:79:62)
    at loadPrivatePartialConfig.next (<anonymous>)
    at loadFullConfig (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/full.js:36:46)
    at loadFullConfig.next (<anonymous>)
    at transform (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/transform.js:20:45)
    at transform.next (<anonymous>)
    at evaluateSync (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/gensync/index.js:251:28)
    at sync (/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/gensync/index.js:89:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/files/plugins.js',
    '/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/config/files/index.js',
    '/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/node_modules/@babel/core/lib/index.js',
    '/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/dist/src/lib/complexity/cyclomatic.js',
    '/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/dist/src/lib/complexity/index.js',
    '/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/dist/src/lib/statistics.js',
    '/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/dist/src/lib/index.js',
    '/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/dist/src/io/index.js',
    '/home/peter/.nvm/versions/node/v18.0.0/lib/node_modules/code-complexity/dist/bin/code-complexity.js'
  ]
}

Tested with

Os: Linux

I have no clue what is going wrong. /home/peter/.nvm/versions/node/v14.19.1/lib/node_modules/code-complexity/node_modules/@babel/plugin-transform-typescript is installed.

JohanHeyvaert commented 1 year ago

I've got more or less the same problem, but on my end the error is "Cannot find module '@babel/preset-env'".

Require stack:

cliffano commented 1 year ago

Same here with Cannot find module '@babel/preset-env on halstead or cyclomatic complexities.

ghost commented 1 year ago

Same here with Cannot find module '@babel/preset-env on halstead or cyclomatic complexities.