Angular 7 CI rxjs/Operators cannot find module

喜你入骨 提交于 2021-01-28 22:45:59

问题


I have tried setting up CI for my angular project using Circle CI following this configuration: https://angular.io/guide/testing#configure-project-for-circle-ci

However, when ng test runs I get the following error:

ERROR in src/app/account/login-form/login-form.component.ts(4,26): error TS2307: Cannot find module 'rxjs/Operators'.

Locally, if I delete node_modules/ and run npm install followed by npm test I don't have any issue with rxjs.

My package.json:

"dependencies": {
  "@angular/animations": "7.2.4",
  "@angular/common": "7.2.4",
  "@angular/compiler": "7.2.4",
  "@angular/core": "7.2.4",
  "@angular/forms": "7.2.4",
  "@angular/http": "7.2.4",
  "@angular/platform-browser": "7.2.4",
  "@angular/platform-browser-dynamic": "7.2.4",
  "@angular/platform-server": "7.2.4",
  "@angular/router": "7.2.4",
  "@ng-bootstrap/ng-bootstrap": "^4.0.2",
  "@nguniversal/module-map-ngfactory-loader": "7.1.0",
  "angularx-social-login": "^1.2.6",
  "aspnet-prerendering": "^3.0.1",
  "bootstrap": "^4.2.1",
  "core-js": "^2.5.4",
  "rxjs": "^6.4.0",
  "zone.js": "^0.8.29"
},
"devDependencies": {
  "@angular-devkit/build-angular": "~0.13.0",
  "@angular/cli": "~7.3.0",
  "@angular/compiler-cli": "7.2.4",
  "@angular/language-service": "^7.2.4",
  "@types/jasmine": "~2.8.6",
  "@types/jasminewd2": "~2.0.3",
  "@types/node": "~8.9.4",
  "bootstrap-sass": "3.4.0",
  "codelyzer": "~4.5.0",
  "jasmine-core": "~2.99.1",
  "jasmine-spec-reporter": "~4.2.1",
  "karma": "^3.0.0",
  "karma-chrome-launcher": "~2.2.0",
  "karma-coverage-istanbul-reporter": "~1.4.2",
  "karma-jasmine": "~1.1.1",
  "karma-jasmine-html-reporter": "^0.2.2",
  "typescript": "~3.2.4"
},
"optionalDependencies": {
  "node-sass": "4.11.0",
  "protractor": "~5.4.0",
  "ts-node": "~5.0.1",
  "tslint": "~5.9.1"
}

The offending lines in login-form.component.ts:

import { Subscription } from 'rxjs';
import { finalize } from 'rxjs/Operators';

I can provide any source on here that is helpful but I don't know what is relevant.


回答1:


That's because you should import from rxjs/operators, not rxjs/Operators.



来源:https://stackoverflow.com/questions/54755950/angular-7-ci-rxjs-operators-cannot-find-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!