I upgraded angular 7.X to angular 8.2.5. This is successful, and my application still runs. However, the angular/core
module throws errors, claiming it cannot find rxjs
. My version of rxjs
is 6.5.3, which is brand new as of this writing.I have uninstalled rxjs-compat
and reran npm install
but the behavior did not change.
(Text version for google searches:)
ERROR in ../../../../../node_modules/@angular/core/src/application_ref.d.ts:8:28 - error TS2307: Cannot find module 'rxjs'.
8 import { Observable } from 'rxjs';
~~~~~~
../../../../../node_modules/@angular/core/src/event_emitter.d.ts:8:39 - error TS2307: Cannot find module 'rxjs'.
8 import { Subject, Subscription } from 'rxjs';
~~~~~~
../../../../../node_modules/@angular/core/src/linker/query_list.d.ts:8:28 - error TS2307: Cannot find module 'rxjs'.
8 import { Observable } from 'rxjs';
~~~~~~
../../../../../node_modules/@angular/core/src/util/lang.d.ts:8:28 - error TS2307: Cannot find module 'rxjs'.
8 import { Observable } from 'rxjs';
Subsequent compiles yield a similar but more compact error. For now, this does not seem to impact my application, it still runs.
What actions can I try to get rid of this error?
Package.json:
{
"name": "myapp-ng",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~8.2.5",
"@angular/cdk": "^7.3.7",
"@angular/common": "~8.2.5",
"@angular/compiler": "~8.2.5",
"@angular/core": "~8.2.5",
"@angular/forms": "~8.2.5",
"@angular/platform-browser": "~8.2.5",
"@angular/platform-browser-dynamic": "~8.2.5",
"@angular/router": "~8.2.5",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"angular2-prettyjson": "^3.0.1",
"core-js": "^2.5.4",
"guid-typescript": "^1.0.9",
"install": "^0.12.2",
"ngx-sortablejs": "^3.1.3",
"node-sass": "^4.12.0",
"npm": "^6.10.2",
"rxjs": "^6.5.3",
"sortablejs": "^1.10.0-rc3",
"tslib": "^1.9.0",
"uninstall": "0.0.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.3",
"@angular/cli": "~8.3.3",
"@angular/compiler-cli": "~8.2.5",
"@angular/language-service": "~8.2.5",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^8.9.5",
"codelyzer": "^5.0.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.5.3"
}
}
EDIT: I found the issue. There was rogue node_modules directory somewhere on ../../../../../ (which was clearly in the error logs mentioned above, but didn't seem suspicious considering the nested nature of npm projects). I don't know why or how but this directory was scanned and spewed errors - this explains why the app was running fine, because the node_modules directory in my project was just fine. I have deleted this rogue node_modules directory and the errors are now gone.
Few thing to check:
Delete any package-lock.json or yarn-lock.json (Normally you install old version when you have this file, deleting it allows you to have a freshly installed package).
Run npm cache clean --force
.
Delete node_modules folder.
Run npm i
again.
Delete the node_modules
and try to run npm install
.
npm uninstall --save rxjs
Then try this:
npm install --save rxjs
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.