如何将 Angular 项目版本从 12.2.5 降级到 12.2.1?

Posted

技术标签:

【中文标题】如何将 Angular 项目版本从 12.2.5 降级到 12.2.1?【英文标题】:How to downgrade Angular project version from 12.2.5 to 12.2.1? 【发布时间】:2021-12-26 18:19:23 【问题描述】:

我有一个版本为 12.2.5 的 Angular 项目。我们正在使用微前端架构。所有其他 Angular 项目都使用 12.2.1 版本。我的项目使用的是 12.2.5。一些 css 和动画无法正常工作。有没有办法将其降级到 12.2.1。我的 pacakage.json 文件如下。


  "name": "xyz",
  "version": "0.0.0",
  "scripts": 
    "ng": "ng",
    "start": "ng serve",
  ,
  "private": true,
  "dependencies": 
    "@angular-architects/module-federation": "^12.5.0",
    "@angular-architects/module-federation-runtime": "^12.5.0",
    "@angular/animations": "12.2.5",
    "@angular/common": "^12.2.6",
    "@angular/compiler": "12.2.5",
    "@angular/core": "^12.2.6",
    "@angular/forms": "^12.2.6",
    "@angular/platform-browser": "12.2.5",
    "@angular/platform-browser-dynamic": "12.2.5",
    "@angular/platform-server": "12.2.5",
    "@angular/router": "^12.2.6",
    "@nguniversal/module-map-ngfactory-loader": "8.1.1",
    "@ngx-translate/core": "^13.0.0",
    "file-saver": "^2.0.5",
    "moment": "^2.29.1",
    "moment-timezone": "^0.5.33",
    "raleway-webfont": "^3.0.1",
    "rxjs": "^6.6.3",
    "tslib": "^2.0.0",
    "xlsx": "^0.17.3",
    "zone.js": "~0.11.4"
  ,
  "devDependencies": 
    "@angular-builders/custom-webpack": "^12.1.2",
    "@angular-devkit/build-angular": "~12.2.5",
    "@angular-eslint/builder": "12.4.1",
    "@angular-eslint/eslint-plugin": "12.4.1",
    "@angular-eslint/eslint-plugin-template": "12.4.1",
    "@angular-eslint/schematics": "12.4.1",
    "@angular-eslint/template-parser": "12.4.1",
    "@angular/cli": "^12.2.5",
    "@angular/compiler-cli": "^12.2.5",
    "@angular/language-service": "^12.2.5",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.8",
    "@types/node": "^12.11.1",
    "@typescript-eslint/eslint-plugin": "4.28.2",
    "@typescript-eslint/parser": "4.28.2",
    "codelyzer": "^6.0.0",
    "eslint": "^7.32.0",
    "html-webpack-plugin": "^5.5.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "typescript": "4.3.5",
    "webpack": "^5.52.1"
  ,
  "optionalDependencies": 
    "protractor": "~7.0.0",
    "ts-node": "~8.4.1"
  ,
  "resolutions": 
    "webpack": "^5.0.0"
  

【问题讨论】:

【参考方案1】:

1-您必须清除 node_modules 文件夹(如果可以,请备份)

2-在 package.json 文件中指定所有 Angular 包的版本号

  "@angular/cli": "12.2.1"

3- 运行 npm install 命令

【讨论】:

以上是关于如何将 Angular 项目版本从 12.2.5 降级到 12.2.1?的主要内容,如果未能解决你的问题,请参考以下文章

如何将复杂项目从 Angular 1.5 迁移到 2?

Angular2:如何将选定项目从 HTML 数据列表元素传递回组件?

如何从 Angular 4 更新/升级到 Angular 5+

如何将此 javascript 和 HTML 代码添加到 Angular 项目中?我可以从 javascript 函数中以角度呈现 html 吗?

如何使用 CLI 创建特定版本的 Angular 项目?

无法将 Angular 从版本 6 降级到 5