Environment:
OS: Linux Mint 18 Cinnamon 64-bit
NPM: 5.6.0
Node: v10.0.0
Ionic: 3.20.0
How I receive this error
I was following this tutorial to apply firebase to an ionic project using angularfire2. I follow the tutorial exactly until I receive an error while running
$ ionic serve
The full error is like this:
typescript: home/brian/node_modules/angularfire2/angularfire2.d.ts, line: 1
Cannot find module '@angular/core'.
L1: import { InjectionToken, NgZone } from '@angular/core';
L2: import { Observable, Subscription } from 'rxjs';
typescript: home/brian/node_modules/angularfire2/angularfire2.d.ts, line: 2
Cannot find module 'rxjs'.
L1: import { InjectionToken, NgZone } from '@angular/core';
L2: import { Observable, Subscription } from 'rxjs';
L3: import { FirebaseOptions, FirebaseAppConfig } from '@firebase/app-types';
typescript: home/brian/node_modules/angularfire2/auth/auth.d.ts, line: 3
Cannot find module '@angular/core'.
L2: import { FirebaseOptions, FirebaseAppConfig } from '@firebase/app-types';
L3: import { NgZone } from '@angular/core';
L4: import { Observable } from 'rxjs';
typescript: home/brian/node_modules/angularfire2/auth/auth.d.ts, line: 4
Cannot find module 'rxjs'.
L3: import { NgZone } from '@angular/core';
L4: import { Observable } from 'rxjs';
L5: export declare class AngularFireAuth {
typescript: home/brian/node_modules/angularfire2/firebase.app.module.d.ts, line: 1
Cannot find module '@angular/core'.
L1: import { InjectionToken } from '@angular/core';
L2: import { FirebaseApp as _FirebaseApp, FirebaseOptions, FirebaseAppConfig } from '@firebase/app-types';
Traceback
Tracing back, when I was installing angularfire2 through command line, I run this command (following the documentation)
npm install firebase angularfire2 --save
And it returns this:
npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EAI_AGAIN: request to https://registry.npmjs.org/firebase failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org registry.npmjs.org:443
npm WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
npm WARN angularfire2@5.0.0-rc.7 requires a peer of @angular/common@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.7 requires a peer of @angular/core@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.7 requires a peer of @angular/platform-browser@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.7 requires a peer of @angular/platform-browser-dynamic@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.7 requires a peer of @firebase/app@^0.1.6 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.7 requires a peer of rxjs@^5.5.4 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.7 requires a peer of zone.js@^0.8.0 but none is installed. You must install peer dependencies yourself.
npm WARN bin@1.0.0 No description
npm WARN bin@1.0.0 No repository field.
+ angularfire2@5.0.0-rc.7
+ firebase@5.0.2
updated 2 packages in 80.502s
Then I try to run the same command again, now it returns almost the same as above but without the npm WARN registry.
npm WARN angularfire2@5.0.0-rc.8.0 requires a peer of @angular/common@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.8.0 requires a peer of @angular/core@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.8.0 requires a peer of @angular/platform-browser@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.8.0 requires a peer of @angular/platform-browser-dynamic@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.8.0 requires a peer of rxjs@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.8.0 requires a peer of zone.js@^0.8.0 but none is installed. You must install peer dependencies yourself.
npm WARN bin@1.0.0 No description
npm WARN bin@1.0.0 No repository field.
The file package.json is located in /home/brian and it contains the lines below.
{
"name": "bin",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"angular": "^1.7.0",
"angularfire2": "^5.0.0-rc.8.0",
"cordova": "^8.0.0",
"firebase": "^5.0.2",
"ionic": "^3.20.0",
"npm": "^6.0.1"
}
}
There is this text in browser after i run $ ionic serve
Ionic Framework: 3.9.2
Ionic App Scripts: 3.1.9
Angular Core: 5.2.10
Angular Compiler CLI: 5.2.10
Node: 10.0.0
OS Platform: Linux 4.4
Navigator Platform: Linux x86_64
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0
I think I installed angularfire on the same location as npm and node, because I run all these installation command in my default location when opening command line. It should be in /home/brian. I also have this folder /home/brian/node_modules.
My Google research to solve this
This similar thread says that we need to rename @angular to @angular2, but I found it returns same error.
Does anyone ever experience the same issue? Any help would be appreciated.