[FIXED] Why i receive error message while install typeorm?

Issue

I tried to build my project with Jenkins.

Node version: 16.16.0

Npm version: 8.11.0

Env: Ubuntu 20.04.4 LTS

Jenkins pulled git repo and tried to install dependencies.
I installed nodejs plugin to jenkins.

If i tried run npm i manually from /var/lib/jenkins/workspace it shows me same error log.

npm i working correctly on my local machine (Windows 10)
Also i tried to re-install node and npm with versions from my local machine, but nothing happened 🙁

My error log:

00:07:51 npm ERR! code ERESOLVE
00:07:51 npm ERR! ERESOLVE could not resolve
00:07:51 npm ERR! 
00:07:51 npm ERR! While resolving: @nestjs/typeorm@8.0.3
00:07:51 npm ERR! Found: typeorm@0.3.6
00:07:51 npm ERR! node_modules/typeorm
00:07:51 npm ERR!   typeorm@"^0.3.6" from the root project
00:07:51 npm ERR! 
00:07:51 npm ERR! Could not resolve dependency:
00:07:51 npm ERR! peer typeorm@"^0.2.34" from @nestjs/typeorm@8.0.3
00:07:51 npm ERR! node_modules/@nestjs/typeorm
00:07:51 npm ERR!   @nestjs/typeorm@"^8.0.3" from the root project
00:07:51 npm ERR! 
00:07:51 npm ERR! Conflicting peer dependency: typeorm@0.2.45
00:07:51 npm ERR! node_modules/typeorm
00:07:51 npm ERR!   peer typeorm@"^0.2.34" from @nestjs/typeorm@8.0.3
00:07:51 npm ERR!   node_modules/@nestjs/typeorm
00:07:51 npm ERR!     @nestjs/typeorm@"^8.0.3" from the root project
00:07:51 npm ERR! 
00:07:51 npm ERR! Fix the upstream dependency conflict, or retry
00:07:51 npm ERR! this command with --force, or --legacy-peer-deps
00:07:51 npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
00:07:51 npm ERR! 
00:07:51 npm ERR! See /var/lib/jenkins/.npm/eresolve-report.txt for a full report.
00:07:51 
00:07:51 npm ERR! A complete log of this run can be found in:
00:07:51 npm ERR!     /var/lib/jenkins/.npm/_logs/2022-07-20T21_07_43_903Z-debug-0.log

package.json file:

{
  "name": "teach-me-grow",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  "dependencies": {
    "@nestjs/common": "^8.0.0",
    "@nestjs/core": "^8.0.0",
    "@nestjs/passport": "^8.2.1",
    "@nestjs/platform-express": "^8.0.0",
    "@nestjs/swagger": "^5.2.1",
    "@nestjs/typeorm": "^8.0.3",
    "class-validator": "^0.13.2",
    "connect-typeorm": "^1.1.4",
    "dotenv": "^16.0.1",
    "express-session": "^1.17.3",
    "module-alias": "^2.2.2",
    "passport": "^0.5.3",
    "passport-facebook": "^3.0.0",
    "passport-google-oauth20": "^2.0.0",
    "passport-local": "^1.0.0",
    "pg": "^8.7.3",
    "pg-hstore": "^2.3.4",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^7.2.0",
    "swagger-ui-express": "^4.4.0",
    "typeorm": "^0.3.6"
  },
  "devDependencies": {
    "@nestjs/cli": "^8.0.0",
    "@nestjs/schematics": "^8.0.0",
    "@nestjs/testing": "^8.0.0",
    "@types/express": "^4.17.13",
    "@types/jest": "27.5.0",
    "@types/node": "^16.0.0",
    "@types/supertest": "^2.0.11",
    "@typescript-eslint/eslint-plugin": "^5.0.0",
    "@typescript-eslint/parser": "^5.0.0",
    "eslint": "^8.0.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.0.0",
    "jest": "28.0.3",
    "prettier": "^2.3.2",
    "source-map-support": "^0.5.20",
    "supertest": "^6.1.3",
    "ts-jest": "28.0.1",
    "ts-loader": "^9.2.3",
    "ts-node": "^10.0.0",
    "tsconfig-paths": "4.0.0",
    "typescript": "^4.3.5"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  },
  "_moduleAliases": {
    "@app": "./dist"
  }
}

Solution

Looking on nestjs/typeorm in version 8.0.3 it has fixed version of typeorm package in its dependencies (package.json: https://github.com/nestjs/typeorm/blob/8.0.3/package.json)
If you want to stick to nestjs/typeorm 8.0.3 version lower your typeorm version to 0.2.45 or upgrade nestjs/typeorm version to one which uses newer typeorm version

Answered By – Damian Sowiński

Answer Checked By – Candace Johnson (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published