Home > Mobile >  npm install not working in angular project
npm install not working in angular project

Time:01-11

Runnig npm install command is giving errors.

THE ERROR:

``
PS D:\t> npm install
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/typescript
npm ERR!   dev typescript@"~4.9.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer typescript@">=4.8.2 <4.9" from @angular/[email protected]
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   dev @angular/compiler-cli@"~15.0.4" from the root project
npm ERR!   peer @angular/compiler-cli@"15.0.4" from @angular/[email protected]
npm ERR!   node_modules/@angular/localize
npm ERR!     dev @angular/localize@"^15.0.4" from the root project
npm ERR!     1 more (@ng-bootstrap/ng-bootstrap)
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 C:\Users\sayed.hussainullah\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\sayed.hussainullah\AppData\Local\npm-cache\_logs\2023-01-11T06_57_30_299Z-debug-0.log
``

Global angular version:

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 15.0.5
Node: 16.16.0
Package Manager: npm 8.17.0
OS: win32 x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1500.5 (cli-only)
@angular-devkit/core         15.0.5 (cli-only)
@angular-devkit/schematics   15.0.5 (cli-only)
@schematics/angular          15.0.5 (cli-only)

Package.json file:

{
    "name": "public_services",
    "version": "1.0.0",
    "license": "",
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
        "@angular/animations": "~15.0.4",
        "@angular/cdk": "^15.0.4",
        "@angular/common": "~15.0.4",
        "@angular/compiler": "~15.0.4",
        "@angular/core": "~15.0.4",
        "@angular/forms": "~15.0.4",
        "@angular/platform-browser": "~15.0.4",
        "@angular/platform-browser-dynamic": "~15.0.4",
        "@angular/router": "15.0.4",
        "@fortawesome/angular-fontawesome": "^0.12.1",
        "@fortawesome/fontawesome-svg-core": "^6.2.1",
        "@fortawesome/free-brands-svg-icons": "^6.2.1",
        "@fortawesome/free-regular-svg-icons": "^6.2.1",
        "@fortawesome/free-solid-svg-icons": "^6.2.1",
        "@ng-bootstrap/ng-bootstrap": "14.0.1",
        "@ng-select/ng-select": "^10.0.3",
        "@ngx-translate/core": "^14.0.0",
        "@ngx-translate/http-loader": "7.0.0",
        "@swimlane/ngx-datatable": "^20.1.0",
        "angular-archwizard": "7.0.0",
        "angular-feather": "^6.5.0",
        "bootstrap": "5.2.3",
        "chart.js": "^4.1.2",
        "classlist.js": "1.1.20150312",
        "core-js": "3.27.1",
        "date-fns": "2.29.3",
        "gulp": "4.0.2",
        "hopscotch": "0.3.1",
        "intl": "1.2.5",
        "moment": "2.29.4",
        "ng-lazyload-image": "^9.1.3",
        "ng2-charts": "^4.1.1",
        "ng2-file-upload": "3.0.0",
        "ng2-img-cropper": "0.9.0",
        "ng2-jalali-date-picker": "^2.2.8",
        "ngx-bootstrap": "^10.2.0",
        "ngx-chips": "3.0.0",
        "ngx-datatable": "^1.0.3",
        "ngx-dropzone-wrapper": "^13.0.0",
        "ngx-perfect-scrollbar": "^7.2.1",
        "ngx-toastr": "16.0.2",
        "node-sass": "^8.0.0",
        "nouislider": "15.6.1",
        "prismjs": "1.29.0",
        "resize-observer-polyfill": "1.5.1",
        "rxjs": "7.8.0",
        "screenfull": "6.0.2",
        "sweetalert2": "11.6.16",
        "tslib": "^2.4.1",
        "web-animations-js": "^2.3.2",
        "xlsx": "^0.18.5",
        "zone.js": "~0.12.0"
    },
    "devDependencies": {
        "@angular-devkit/build-angular": "~15.0.5",
        "@angular/cli": "~15.0.5",
        "@angular/compiler-cli": "~15.0.4",
        "@angular/language-service": "~15.0.4",
        "@angular/localize": "^15.0.4",
        "@types/core-js": "2.5.5",
        "@types/jasmine": "^4.3.1",
        "@types/jasminewd2": "~2.0.10",
        "@types/jquery": "^3.5.16",
        "@types/node": "^18.11.18",
        "codelyzer": "^6.0.2",
        "jasmine-core": "~4.5.0",
        "jasmine-spec-reporter": "~7.0.0",
        "karma": "~6.4.1",
        "karma-chrome-launcher": "~3.1.1",
        "karma-cli": "~2.0.0",
        "karma-coverage-istanbul-reporter": "~3.0.3",
        "karma-jasmine": "~5.1.0",
        "karma-jasmine-html-reporter": "^2.0.0",
        "protractor": "~7.0.0",
        "rxjs-compat": "6.6.7",
        "ts-node": "~10.9.1",
        "tslint": "~6.1.0",
        "typescript": "~4.9.4"

    }
}

I have tried:

  • delete node modules.
  • clear cache.
  • unistall node.js and reinstall lower version.
  • installed msbuild-tools.

so far non-of these methods worked

CodePudding user response:

You should try running npm install --legacy-peer-deps, in order to ignore dependencies between packages. Nevertheless the root cause of your problem is that your installed angular versions expects typescript version >=4.8.2 and <4.9, but 4.9.4 will be installed. So a solution might be to downgrade your typescript version or update your angular versions.

CodePudding user response:

There are limitations of npm's Install Algorithm, So npm will refuse to install any package with an identical name to the current package. It will overridden with the --force flag, but in most cases can simply be addressed by changing the local package name.

So you need to use --force flag to re-install packages again like below:

npm install --force
  • Related