Why yarn ask for ts-jest version when I run install task?

Viewed 29

I am working on a project and each time I execute yarn install I am getting the following message in the console:

? Please choose a version of "ts-jest" from this list: (Use arrow keys)
❯ 29.0.0-next.0 
  28.0.8 
  28.0.7 
  28.0.6 
  28.0.5 
  28.0.4 
  28.0.3 
  28.0.2 

Should I do something to avoid receiving this message? This is what my package.json file looks like:

{
  "name": "xyz",
  "version": "1.0.0",
  "description": "",
  "main": "src/index.js",
  "scripts": {
    "dev": "nodemon dev-server.js",
    "unit": "jest",
    "lint": "eslint '*.ts' --quiet --fix",
    "compile": "tsc",
  },
  "devDependencies": {
    "@types/jest": "^27.5.1",
    "@typescript-eslint/eslint-plugin": "^5.10.2",
    "@typescript-eslint/parser": "^5.10.2",
    "esbuild": "^0.14.14",
    "esbuild-jest": "^0.5.0",
    "eslint": "^8.8.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.0.0",
    "express": "^4.18.1",
    "jest": "^27.5.1",
    "json": "^11.0.0",
    "nodemon": "^2.0.16",
    "prettier": "^2.5.1",
    "ts-jest": "^27.5.1",
    "ts-node": "^10.4.0",
    "typescript": "^4.5.5"
  },
  "dependencies": {
    "uuid": "^8.3.2"
  }
}

2 Answers

What finally ended up working for me was updating the jest and ts-jest dependency versions as follows:

"jest": "^28.0.3",
"ts-jest": "^28.0.3",

You should remove ^ prefix from the value of the ts-jest entry, so yarn uses only the specified version.

Thus "ts-jest": "^27.5.1" would become "ts-jest": "27.5.1"

For more info about version ranges check out node-semver README

Related