简体   繁体   中英

Angular app error when running npm install - Could not resolve dependency

I have an Angular 9 (* UPDATE, this is meant to be Angular 11), that has bee developed on Ubuntu and Mac machines. The following command works no problem:

npm install

So now I need to deploy it to a Linux Centos 7 server. So I have Dockerized it. When the Dockerfile wants to execute npm install , it gets the following error:

Step 4/13 : RUN npm install
 ---> Running in 42f10bf7732c
npm notice 
npm notice New patch version of npm available! 7.4.0 -> 7.4.3
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.4.3>
npm notice Run `npm install -g npm@7.4.3` to update!
npm notice 
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: nexct-ng-ui@0.0.0
npm ERR! Found: @angular/common@11.0.9
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"~11.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^10.2.2" from angular-datatables@10.1.0
npm ERR! node_modules/angular-datatables
npm ERR!   angular-datatables@"^10.0.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-01-27T12_02_45_235Z-debug.log

Ay ideas?

Additional info:

I tried looking at the suggested logs:

/root/.npm/eresolve-report.txt: No such file or directory
/root/.npm/_logs/2021-01-27T12_02_45_235Z-debug.log: No such file or directory

package.json

{
  "name": "nexct-ng-ui",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~11.0.0",
    "@angular/common": "~11.0.0",
    "@angular/compiler": "~11.0.0",
    "@angular/core": "~11.0.0",
    "@angular/forms": "~11.0.0",
    "@angular/platform-browser": "~11.0.0",
    "@angular/platform-browser-dynamic": "~11.0.0",
    "@angular/router": "~11.0.0",
    "@fortawesome/fontawesome-free": "^5.15.1",
    "angular-datatables": "^10.0.0",
    "bootstrap": "^4.5.3",
    "datatables.net": "^1.10.22",
    "datatables.net-dt": "^1.10.22",
    "jquery": "^3.5.1",
    "ng-recaptcha": "^6.0.2",
    "popper.js": "^1.16.1",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1100.1",
    "@angular/cli": "~11.0.1",
    "@angular/compiler-cli": "~11.0.0",
    "@types/datatables.net": "^1.10.19",
    "@types/jasmine": "~3.6.0",
    "@types/jquery": "^3.5.4",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.1.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.2"
  }
}

You are saying your application is written in ng 9 but there are some lines in error like npm ERR: Found. @angular/common@11.0.9 npm ERR: Found. @angular/common@11.0.9 and angular-datatables@"^10.0.0" where ng version is 11. this might be the issue as there is a dependency between angular-datatables version 10.0.0 and angular 11. Fix that and it will work just fine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM