Module not found: Error: Can't resolve 'angularfire2' in '..' -- Angular 4
I saw more people with this problem in the Issues, but I wasn't able to resolve my problem with that informatie.
When I run ng serve I get the follow error:
ERROR in ./src/app/app.component.ts Module not found: Error: Can't resolve 'angularfire2' in '......'
I am using angular 4
My package.json looks like this:
{ "name": "xxxxxxx", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^4.0.1", "@angular/common": "^4.0.1", "@angular/compiler": "^4.0.1", "@angular/compiler-cli": "^4.0.1", "@angular/core": "^4.0.1", "@angular/forms": "^4.0.1", "@angular/http": "^4.0.1", "@angular/platform-browser": "^4.0.1", "@angular/platform-browser-dynamic": "^4.0.1", "@angular/platform-server": "^4.0.1", "@angular/router": "^4.0.1", "core-js": "^2.4.1", "rxjs": "^5.1.0", "typescript": "^2.2.2", "zone.js": "^0.8.4" }, "devDependencies": { "@angular/cli": "1.0.0", "@angular/compiler-cli": "^4.0.0", "@types/jasmine": "2.5.38", "@types/node": "~6.0.60", "codelyzer": "~2.0.0", "jasmine-core": "~2.5.2", "jasmine-spec-reporter": "~3.2.0", "karma": "~1.4.1", "karma-chrome-launcher": "~2.0.0", "karma-cli": "~1.0.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "karma-coverage-istanbul-reporter": "^0.2.0", "protractor": "~5.1.0", "ts-node": "~2.0.0", "tslint": "~4.5.0", "typescript": "~2.2.0" } }
Can anyone help me?
I think is was because Firebase itself wasn't installed right. This did it for me:
npm install firebase angularfire2 --save
Is there a solution for this?? I can do 'ionic cordova build browser' perfectly fine, it works great. However, every single time I do 'ionic cordova build browser --prod' I get a ton of errors and they all have
"Module not found: Error: Can't resolve '../../../angularfire2/database'"
I have done ionic cordova platform rm browser, then ionic cordova platform add browser. I have done npm install firebase angularfire2 --save, and still, it will only build normal, every time I try to build -prod I get can't resolve '../../../angularfire2/database' and "Field 'browser' doesn't contain a valid alias configuration" Please help, I need to build this project. I will be more than happy to give my package.json and my app.module.ts file if it will help. Thank you.
@danwguy downgrade to [email protected] worked for me on mac
same thing as @andr3medeiros said...i could ionic serve and ionic build, but ionic build --prod would fail, thinking that angular2/database was a relative reference to a module, instead of looking in the node_modules folder.
downgrading to [email protected] solved it for me too. on windows
Downgrading to [email protected] did it for me. Thanks @andr3medeiros !
Downgrading to [email protected] works for me too, I'm on Mac.
I am having this issue. Downgrading to [email protected] did not help.
I have to do a clean install of the dependencies, remove angularfire2 and install [email protected]. That seems to work. Here are the steps:
-
delete
node_modulesfolder -
in
package.jsonfile, delete angularfire2 in dependencies -
npm install -
npm install --save [email protected] -
ionic cordova build android --prod
Why is the issue closed though? Any hopes to get this working without having to downgrade? Thank you!
Thanks alltej, same problem, same solution :-) But still having to downgrade in 2018?!
Same problem.
I know this is about Angular 4, here's the Angular 6 update:
npm install --save firebase angularfire2
[email protected]: AngularFire has moved, we're now @angular/fire
import { AngularFireModule } from '@angular/fire'; import { AngularFireDatabaseModule } from 'angularfire2/database';
npm install -S angularfire2@latest
just run this command, then you will be able to find to angularfire2/firestore