0

根据stackoverflow这个帖子链接的指南,我尝试将我的angular 5项目升级到6但是当我 ng update @angular/cli得到错误“序列中没有元素”而没有其他信息时我该如何修复它?我也不能再开始我的项目了Local workspace file ('angular.json') could not be found.

这也是我的 package.json:我尝试使用"rxjs": "^5.5.4"pathMatch: 'full'连接到我的路由器,但对我没有用

{
  "name": "m4user",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/schematics": "0.0.45",
    "@angular/animations": "^5.2.3",
    "@angular/cdk": "^5.2.4",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/flex-layout": "^5.0.0-beta.14",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/material": "^5.2.0",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "@auth0/angular-jwt": "^1.1.0",
    "@ecodev/fab-speed-dial": "0.0.4",
    "@floydspace/ngx-validation": "^1.0.3",
    "@mdi/font": "^2.2.43",
    "@types/moment": "^2.13.0",
    "@types/raphael": "^2.1.30",
    "angular-captcha": "^3.0.6",
    "angular-typing-animation": "^0.5.4",
    "angularx-social-login": "^1.1.8",
    "chart.js": "^2.7.2",
    "core-js": "^2.4.1",
    "driver": "^1.0.0",
    "driver.js": "^0.3.8",
    "file-saver": "latest",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "jquery": "^3.3.1",
    "jwt-decode": "^2.2.0",
    "materialize-css": "^0.100.2",
    "mdi": "^2.2.43",
    "ngx-contextmenu": "^4.1.2",
    "ngx-cookie-service": "^1.0.10",
    "ngx-uploader": "^4.2.2",
    "plyr": "^3.0.3",
    "raphael": "^2.2.7",
    "recordrtc": "^5.4.6",
    "roughjs": "^2.0.1",
    "rxjs": "5.5.4",
    "save": "^2.3.2",
    "sweetalert2": "^7.15.0",
    "videogular2": "^6.0.6",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular/cli": "^6.0.1",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/chartjs": "^0.0.31",
    "@types/core-js": "^0.9.46",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/jwt-decode": "^2.2.1",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "ngx-validators": "^3.0.0",
    "persian-date": "^1.0.5",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": ">=2.4.2 <2.7.0"
  }
}
4

2 回答 2

2

当使用带有 angular 的 RxJS 5.5.4(版本 4/5)时会发生此错误,因此只需跳过 RxJS 5.5.4,并通过添加“rxjs”:“^5.5”来使用 RxJS 5.5.4。到您的项目 package.json。也使用这可能会有所帮助

 npm i -g rxjs-tslint
rxjs-5-to-6-migrate -p [path/to/tsconfig.json]
于 2018-05-11T06:07:47.270 回答
2

在做之前ng update @angular/cli,你只需要将你的@angular/cli包升级到最新版本。

 > npm uninstall -g @angular/cli 

 > npm install -g @angular/cli ( if throws an error then run npm cache clean --f & try again this command)

然后删除node_modules文件夹。

  • 创建一个新的 Angular v6 项目

  • 将新项目中的 package.json 与现有项目进行比较

  • 更新 package.json 中的包版本

  • 然后依次npm update运行ng build --prod

  • 您可能会遇到 Rxjs 错误,如果您不想更新任何现有代码,请安装 rxjs/compat 包

npm install --save rxjs/compat

现在最后你需要用 angular.json 文件替换你的 angular-cli.json 文件。运行ng update @angular/cli。检查 angular.json 文件中的配置设置。

而已。

您可以随时参考https://update.angular.io/

于 2018-05-11T06:19:51.357 回答