Last modified: Jun 30, 2025 By Alexander Williams

Fix Error: Cannot find module 'ts-jest'

If you see the error Cannot find module 'ts-jest', don't worry. This is a common issue in Node.js projects using Jest and TypeScript. This guide will help you fix it.

What Causes the Error?

The error occurs when Node.js cannot locate the ts-jest module. This usually happens when the module is not installed or configured correctly.

How to Fix the Error

Follow these steps to resolve the issue:

1. Install ts-jest

First, ensure ts-jest is installed in your project. Run this command in your terminal:


npm install ts-jest --save-dev

If you use Yarn, run:


yarn add ts-jest --dev

2. Check Your jest.config.js

Ensure your jest.config.js file is properly configured. It should include ts-jest as a preset:


module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
};

3. Verify TypeScript Installation

ts-jest requires TypeScript. If you haven't installed it, run:


npm install typescript --save-dev

For more details, see our guide on Fix Error: Cannot find module 'typescript'.

4. Clear Node Modules and Reinstall

Sometimes, dependencies get corrupted. Delete node_modules and package-lock.json, then reinstall:


rm -rf node_modules package-lock.json
npm install

5. Check Global Installation

If you installed ts-jest globally, ensure it's accessible. Run:


npm list -g ts-jest

If it's not installed globally, install it with:


npm install -g ts-jest

Common Mistakes

Here are some common mistakes that cause this error:

  • Misspelling ts-jest in package.json
  • Not adding ts-jest as a dev dependency
  • Incorrect Jest configuration

If you face similar issues with other modules, check our guide on Fix Error: Cannot find module 'jest'.

Example Project Setup

Here’s a basic setup for a project using ts-jest:


{
  "name": "my-project",
  "version": "1.0.0",
  "devDependencies": {
    "ts-jest": "^29.1.1",
    "jest": "^29.7.0",
    "typescript": "^5.3.3"
  }
}

For more complex setups, refer to the Fix Error: Cannot find module 'webpack' guide.

Conclusion

The Cannot find module 'ts-jest' error is easy to fix. Ensure the module is installed and configured correctly. Follow the steps above to resolve it quickly.

If you still face issues, check your project structure and dependencies. Happy coding!