最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

angular - Terminal gets stuck when trying to update Typescript for and Angularv18 project - Stack Overflow

programmeradmin2浏览0评论

I have a an Angular project (which has multiple projects inside) which I updated to Angular v18.2.12. I managed to update all dependencies but TS doesn't let me build, since 4.0.8 is installed but needs either 5.4.0 ro 5.6.0. When I try to run npm i [email protected] the terminal gets stuck in the process of the install, specifically with this segment of code:

npm WARN Could not resolve dependency:
npm WARN peer typescript@">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev" from [email protected]
npm WARN node_modules/tslint
npm WARN   dev tslint@"~5.7.0" from the root project
[#########.........] - idealTree:trunk: timing idealTree:#root Completed in 421ms

Am I doing something wrong?

I have a an Angular project (which has multiple projects inside) which I updated to Angular v18.2.12. I managed to update all dependencies but TS doesn't let me build, since 4.0.8 is installed but needs either 5.4.0 ro 5.6.0. When I try to run npm i [email protected] the terminal gets stuck in the process of the install, specifically with this segment of code:

npm WARN Could not resolve dependency:
npm WARN peer typescript@">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev" from [email protected]
npm WARN node_modules/tslint
npm WARN   dev tslint@"~5.7.0" from the root project
[#########.........] - idealTree:trunk: timing idealTree:#root Completed in 421ms

Am I doing something wrong?

Share Improve this question edited Nov 19, 2024 at 4:49 Naren Murali 61.1k5 gold badges44 silver badges81 bronze badges asked Nov 18, 2024 at 10:57 Lorenzo BertolacciniLorenzo Bertolaccini 874 silver badges13 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

To perform the install without the dependency errors, you can use --legacy-peer-deps argument.

npm i typescript@~5.4.0 --legacy-peer-deps

After installing the correct typescript you have to upgrade tslint to ^6.1.3.

npm i tslint@^6.1.3 --legacy-peer-deps

The legacy peer deps is just to update the package.json with the proper versions, after you do this, there is no need for the --legacy-peer-deps params, npm install should work as it is.

Full Code:

{
  "name": "angular-starter",
  "private": true,
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build"
  },
  "dependencies": {
    "@angular/animations": "^18.2.12",
    "@angular/common": "^18.2.12",
    "@angular/compiler": "^18.2.12",
    "@angular/core": "^18.2.12",
    "@angular/forms": "^18.2.12",
    "@angular/platform-browser": "^18.2.12",
    "@angular/router": "^18.2.12",
    "rxjs": "^7.8.1",
    "tslib": "^2.5.0",
    "zone.js": "~0.14.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^18.2.12",
    "@angular/cli": "^18.2.12",
    "@angular/compiler-cli": "^18.2.12",
    "tslint": "^6.1.3",
    "typescript": "~5.5.0"
  }
}

Stackblitz Demo

发布评论

评论列表(0)

  1. 暂无评论