Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 'ts-node' is required for the TypeScript configuration files #15431

Open
hamzahamidi opened this issue Dec 30, 2024 · 0 comments
Open

Comments

@hamzahamidi
Copy link

Version

29.2.5

Steps to reproduce

npm install --save-dev jest ts-jest @types/jest
npx ts-jest config:init

jest.config.ts

import type { Config } from 'jest';

const config: Config = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  testMatch: ['tests/**/*.spec.ts'],
  globals: {
    'ts-jest': {
      tsconfig: 'tsconfig.json',
    },
  },
  collectCoverage: true,
  collectCoverageFrom: ['src/**/*.ts'],
  coverageReporters: ['text-summary', 'lcov'],
};

export default config;

package.json

  "scripts": {
    "test": "jest"
  },

Expected behavior

Running npm run test should work successfully.

I'm getting the error

Error: Jest: Failed to parse the TypeScript config file /Users/hhamidi/projects/new-project/jest.config.ts
Error: Jest: 'ts-node' is required for the TypeScript configuration files. Make sure it is installed
Error: Cannot find package 'ts-node' imported from /Users/hhamidi/projects/new-project/node_modules/jest-config/build/readConfigFileAndSetRootDir.js

installing ts-node was not specified in the docs.

Actual behavior

I'm getting the error

Error: Jest: Failed to parse the TypeScript config file /Users/hhamidi/projects/new-project/jest.config.ts
Error: Jest: 'ts-node' is required for the TypeScript configuration files. Make sure it is installed
Error: Cannot find package 'ts-node' imported from /Users/hhamidi/projects/new-project/node_modules/jest-config/build/readConfigFileAndSetRootDir.js

installing ts-node was not specified in the docs.

Additional context

Issue was already mentioned here

Environment

System:
    OS: macOS 14.7
    CPU: (10) arm64 Apple M1 Max
  Binaries:
    Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
  npmPackages:
    jest: ^29.7.0 => 29.7.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant