angularfire: Cannot find module 'angularfire2' when using Angular-CLI and RC.4

I’m using angular-cli with the lastest RC4 version of Angular.

I was following the steps here: https://github.com/angular/angularfire2/blob/master/docs/1-install-and-setup.md

But I had to make a few very small changes. For one, I’m installing AngularFire this way: npm install git+https://github.com/angular/angularfire2.git --save so that I have a version that is compatible with RC4.

Secondly, when doing the typings step I do this: typings install file:node_modules/firebase/firebase.d.ts --save --global && typings install because that’s where the firebase.d.ts file is now it seems.

Next I do this:

var map = {
    'firebase': 'vendor/firebase/firebase.js',
    'angularfire2': 'vendor/angularfire2'
};
/** User packages configuration. */
var packages = {
    angularfire2: {
        defaultExtension: 'ts',
        main: 'angularfire2.ts'
    }
};

Where I use the .ts file because there isn’t a .js file for angularfire2 in the node_modules/angularfire2 folder. Even in the source folder it’s just .ts files.

So, once I get to step 7, and do this: import { FIREBASE_PROVIDERS, defaultFirebase } from 'angularfire2'; everything falls apart. I’m not sure why, it should work?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 58

Most upvoted comments

have you tried installing the angularfire suggested in the setup? Actually that’s what I’m using and its working on RC4.

Believe me, I’m trying to get your error but I can’t. It works fine on me.

May be use npm install angularfire2 firebase --save instead of the github link you are using.

Did you try creating one again from scratch like after you clean the cache and reinstalling cli again? I think i’m getting it right now. I remember i used to get same error before but after reinstalling cli and start from scratch again, like from number 1 in the set up. I finally realize that Im just too excited to code and when i npm install angularfire2 firebase --save I’ve wait until self termination occur, and then the error is gone.

But I dont think you have done this before? Haha. Just trying man, I just help.

I tried npm cache clean and then ran it again:

➜  test-project git:(master) ✗ npm cache clean
➜  test-project git:(master) ✗ npm install angularfire2 firebase --save
test-project@0.0.0 /Users/jasonshultz/Projects/test-project
├── UNMET PEER DEPENDENCY @angular/common@2.0.0-rc.4
├── UNMET PEER DEPENDENCY @angular/compiler@2.0.0-rc.4
├── UNMET PEER DEPENDENCY @angular/core@2.0.0-rc.4
├── UNMET PEER DEPENDENCY @angular/platform-browser@2.0.0-rc.4
├── UNMET PEER DEPENDENCY @angular/platform-browser-dynamic@2.0.0-rc.4
├── angularfire2@2.0.0-beta.2 
└── firebase@3.2.1 

npm WARN angularfire2@2.0.0-beta.2 requires a peer of @angular/core@2.0.0-rc.2 but none was installed.
npm WARN angularfire2@2.0.0-beta.2 requires a peer of @angular/platform-browser@2.0.0-rc.2 but none was installed.
npm WARN angularfire2@2.0.0-beta.2 requires a peer of @angular/common@2.0.0-rc.2 but none was installed.
npm WARN angularfire2@2.0.0-beta.2 requires a peer of @angular/compiler@2.0.0-rc.2 but none was installed.
npm WARN angularfire2@2.0.0-beta.2 requires a peer of @angular/platform-browser-dynamic@2.0.0-rc.2 but none was installed.

May your default extension should be .js and not .ts ?

Here is my packages:

const packages: any = {
  angularfire2: {
    dafaultExtension: 'js',
    main: 'angularfire2.js'
  }
};

Its actually working on my side.