vuejs/vue-cli · error · Error

Cannot resolve "ts-jest" module. Typescript preset requires

Error message

Cannot resolve "ts-jest" module. Typescript preset requires "ts-jest" to be installed.

What it means

The typescript jest preset extends the default preset and needs `ts-jest` to transform `.ts`/`.tsx` files. It resolves `ts-jest` via require.resolve and throws if the module is absent, because the transform entry would otherwise point at nothing.

Source

Thrown at packages/@vue/cli-plugin-unit-jest/presets/typescript/jest-preset.js:8

const deepmerge = require('deepmerge')
const defaultPreset = require('../default/jest-preset')

let tsJest = null
try {
  tsJest = require.resolve('ts-jest')
} catch (e) {
  throw new Error('Cannot resolve "ts-jest" module. Typescript preset requires "ts-jest" to be installed.')
}

module.exports = deepmerge(
  defaultPreset,
  {
    moduleFileExtensions: ['ts', 'tsx'],
    transform: {
      '^.+\\.tsx?$': tsJest
    }
  }
)

View on GitHub (pinned to 7eb93c169c)

Solutions

  1. Install ts-jest: `npm i -D ts-jest`.
  2. Make sure the ts-jest major is compatible with your Jest major (check ts-jest's peer deps).
  3. Verify the preset path string is correct in jest config.
Defensive patterns

Strategy: validation

Validate before calling

const pkg = require('./package.json')
if (!(pkg.devDependencies || {}).tsJest && !(pkg.devDependencies || {})['ts-jest']) {
  console.warn('Typescript jest preset needs ts-jest: run npm i -D ts-jest')
}

Try / catch

try { require.resolve('ts-jest') } catch { /* install ts-jest, then re-run jest */ }

Prevention

When it happens

Trigger: Pointing Jest's `preset` at `@vue/cli-plugin-unit-jest/presets/typescript/jest-preset` (or the no-type-check variant) without having `ts-jest` installed.

Common situations: TypeScript project set up for Jest with ts-jest missing from devDependencies; ts-jest removed during dependency pruning; version skew between ts-jest and the installed Jest.

Related errors


AI-assisted analysis of vuejs/vue-cli@7eb93c169c (2026-08-13). Data as JSON: /api/errors/e5a82c83539c64f8. Report an issue: GitHub.