【问题标题】:Angular 6 migration issueAngular 6 迁移问题
【发布时间】:2019-09-18 07:54:25
【问题描述】:

我正在从 angular 5 迁移到 angular 6 。当我尝试做服务时,我得到了。

./node_modules/@ng-idle/core/src/eventtargetinterruptsource.js 中的错误 找不到模块:错误:无法解析“C:\Users\infouser\git\branches\Orion-App\orion-ui\node_modules@ng-idle\core\src”中的“rxjs/Subscription” ./node_modules/@ng-idle/core/src/eventtargetinterruptsource.js 中的错误 找不到模块:错误:无法在“C:\Users\infouser\git\branches\Orion-App\orion-ui\node_modules@ng-idle\core\src”中解析“rxjs/add/observable/fromEvent” ./node_modules/@ng-idle/core/src/eventtargetinterruptsource.js 中的错误 找不到模块:错误:无法解析“C:\Users\infouser\git\branches\Orion-App\orion-ui\node_modules@ng-idle\core\src”中的“rxjs/add/observable/merge” ./node_modules/@ng-idle/core/src/eventtargetinterruptsource.js 中的错误 找不到模块:错误:无法解析“C:\Users\infouser\git\branches\Orion-App\orion-ui\node_modules@ng-idle\core\src”中的“rxjs/add/operator/filter” ./node_modules/@ng-idle/core/src/eventtargetinterruptsource.js 中的错误 找不到模块:错误:无法解析“C:\Users\infouser\git\branches\Orion-App\orion-ui\node_modules@ng-idle\core\src”中的“rxjs/add/operator/throttleTime”

这是我的 package.json 文件

{
  "name": "orion-upgrade",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxy.conf.json --disable-host-check",
    "build": "ng build --configuration=develop --prod --aot --output-hashing=all --base-href .",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.10",
    "@angular/cdk": "^6.4.7",
    "@angular/common": "^6.1.10",
    "@angular/compiler": "^6.1.10",
    "@angular/core": "^6.1.10",
    "@angular/flex-layout": "^6.0.0-beta.15",
    "@angular/forms": "^6.1.10",
    "@angular/http": "^6.1.10",
    "@angular/material": "^6.4.7",
    "@angular/platform-browser": "^6.1.10",
    "@angular/platform-browser-dynamic": "^6.1.10",
    "@angular/router": "^6.1.10",
    "@ng-idle/core": "^2.0.0-beta.15",
    "@ng-idle/keepalive": "^2.0.0-beta.15",
    "@types/crypto-js": "^3.1.43",
    "angular-font-awesome": "^3.1.2",
    "core-js": "^2.6.5",
    "crypto-js": "^3.1.9-1",
    "file-saver": "^1.3.8",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "rxjs": "6.1.0",
    "tslib": "^1.9.0",
    "xlsx": "^0.14.2",
    "zone.js": "^0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "^6.2.9",
    "@angular/compiler-cli": "^6.1.10",
    "@angular/language-service": "^6.1.10",
    "@types/jasmine": "^2.8.16",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "^6.14.4",
    "ajv": "^6.10.0",
    "codelyzer": "^4.5.0",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.4.3",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "^2.7.2"
  },
  "description": "This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.6.8.",
  "main": "karma.conf.js",
  "repository": {
    "type": "git",
    "url": "git+ssh://git@bitbucket.org/Yuncheng_He/orion-angular-4.git"
  },
  "author": "",
  "homepage": "https://bitbucket.org/Yuncheng_He/orion-angular-4#readme"
}

谁能告诉我如何解决这个错误。

【问题讨论】:

    标签: angular angular6


    【解决方案1】:

    尝试导入 observables 和操作符,例如

    import { Observable, Subscriber } from 'rxjs';
    import { tap, map, filter } from 'rxjs/operators';
    

    【讨论】:

    • 这个错误在不是我添加的eventtargetinterruptsource.js文件中
    • 是的,但是尝试导入我在答案中提到的 rxjs 模块,我也遇到了同样的错误,这解决了我的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-26
    • 2018-10-18
    • 2023-04-08
    • 1970-01-01
    • 2022-07-15
    • 2011-01-03
    相关资源
    最近更新 更多