Categories
TypeScript Answers

How to fix “cannot find module ‘ts-jest/utils'” error with Jest and TypeScript?

Spread the love

To fix "cannot find module ‘ts-jest/utils’" error with Jest and TypeScript, we install the ts/jest package.

To install it, we run

npm i -D jest typescript
npm i -D ts-jest @types/jest

to install the typescript and ts-jest modules with NPM.

typescript is a prerequisite for the ts-jest module.

Then we create a Jest config with

npx ts-jest config:init

Then we run tests with

npm test 

or

npx jest	

With Yarn, we run

yarn add --dev jest typescript
yarn add --dev ts-jest @types/jest

to install the packages.

We run

yarn ts-jest config:init

to create the Jest config.

And we run

yarn test

or

yarn jest

to run the tests.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *