angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Module not found: Error: Can't resolve 'angularfire2' in '..' -- Angular 4

Open luuksuijkerbuijk opened this issue 9 years ago • 13 comments

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?

luuksuijkerbuijk avatar Apr 04 '17 20:04 luuksuijkerbuijk

I think is was because Firebase itself wasn't installed right. This did it for me:

npm install firebase angularfire2 --save

luuksuijkerbuijk avatar Apr 05 '17 09:04 luuksuijkerbuijk

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 avatar Sep 06 '17 05:09 danwguy

@danwguy downgrade to [email protected] worked for me on mac

andr3medeiros avatar Sep 13 '17 17:09 andr3medeiros

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

rastographics avatar Sep 13 '17 21:09 rastographics

Downgrading to [email protected] did it for me. Thanks @andr3medeiros !

BAWES avatar Sep 15 '17 14:09 BAWES

Downgrading to [email protected] works for me too, I'm on Mac.

Hailong avatar Sep 19 '17 09:09 Hailong

I am having this issue. Downgrading to [email protected] did not help.

alltej avatar Oct 03 '17 11:10 alltej

I have to do a clean install of the dependencies, remove angularfire2 and install [email protected]. That seems to work. Here are the steps:

  1. delete node_modules folder

  2. in package.json file, delete angularfire2 in dependencies

  3. npm install

  4. npm install --save [email protected]

  5. ionic cordova build android --prod

alltej avatar Oct 03 '17 12:10 alltej

Why is the issue closed though? Any hopes to get this working without having to downgrade? Thank you!

CarlosAmaral avatar Oct 30 '17 23:10 CarlosAmaral

Thanks alltej, same problem, same solution :-) But still having to downgrade in 2018?!

RalfViellieber avatar Aug 16 '18 21:08 RalfViellieber

Same problem.

MrDrProfX avatar Aug 31 '18 21:08 MrDrProfX

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';

bobbycv64 avatar Nov 07 '18 01:11 bobbycv64

npm install -S angularfire2@latest

just run this command, then you will be able to find to angularfire2/firestore

muhammadumerfarooq avatar Jan 09 '19 07:01 muhammadumerfarooq