angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

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

Open thehashrocket opened this issue 10 years ago • 58 comments

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?

thehashrocket avatar Jul 31 '16 05:07 thehashrocket

yes, changed to .js and yes, using mac.

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

everything in the repo is exactly what i have locally right now.

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

When you import angularfire in main.ts, does it gives you the same error? Dude, that's so weird. Sorry.

lexcaraig avatar Aug 01 '16 01:08 lexcaraig

@lexcaraig yeah, same error. Doesn't matter if it's .ts or .js. I've never encountered this before. I've worked in other angular2 apps using angular-cli and imported third party libraries and it worked fine. it's only with this situation that i'm hitting this error.

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

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.

lexcaraig avatar Aug 01 '16 01:08 lexcaraig

ok, i'll give it a shot now and see what happens. it shouldn't take that long. just a few minutes.

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

so far:

npm uninstall -g angular-cli npm cache clean npm install -g angular-cli@latest npm install -g angular-cli npm install -g typings
ng new test-project cd test-project

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

npm install angularfire2 firebase --save

got the errors but i'm ignoring them and moving foward.

➜  test-project git:(master) npm install angularfire2 firebase --save

> [email protected] install /Users/jasonshultz/Projects/test-project/node_modules/fsevents
> node-pre-gyp install --fallback-to-build

[fsevents] Success: "/Users/jasonshultz/Projects/test-project/node_modules/fsevents/lib/binding/Release/node-v47-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
[email protected] /Users/jasonshultz/Projects/test-project
├── UNMET PEER DEPENDENCY @angular/[email protected]
├── UNMET PEER DEPENDENCY @angular/[email protected]
├── UNMET PEER DEPENDENCY @angular/[email protected]
├── UNMET PEER DEPENDENCY @angular/[email protected]
├── UNMET PEER DEPENDENCY @angular/[email protected]
├── [email protected] 
├─┬ [email protected] 
│ ├─┬ [email protected] 
│ │ └─┬ [email protected] 
│ │   └── [email protected] 
│ ├─┬ [email protected] 
│ │ ├─┬ [email protected] 
│ │ │ ├─┬ [email protected] 
│ │ │ │ ├─┬ [email protected] 
│ │ │ │ │ ├── [email protected] 
│ │ │ │ │ ├─┬ [email protected] 
│ │ │ │ │ │ ├── [email protected] 
│ │ │ │ │ │ ├── [email protected] 
│ │ │ │ │ │ └── [email protected] 
│ │ │ │ │ └── [email protected] 
│ │ │ │ └─┬ [email protected] 
│ │ │ │   ├─┬ [email protected] 
│ │ │ │   │ ├── [email protected] 
│ │ │ │   │ └── [email protected] 
│ │ │ │   ├─┬ [email protected] 
│ │ │ │   │ ├── [email protected] 
│ │ │ │   │ └─┬ [email protected] 
│ │ │ │   │   └─┬ [email protected] 
│ │ │ │   │     └── [email protected] 
│ │ │ │   ├── [email protected] 
│ │ │ │   └── [email protected] 
│ │ │ └─┬ [email protected] 
│ │ │   ├── [email protected] 
│ │ │   └─┬ [email protected] 
│ │ │     └── [email protected] 
│ │ ├── [email protected] 
│ │ └── [email protected] 
│ └── [email protected] 
├─┬ [email protected]
│ └─┬ [email protected]
│   └─┬ [email protected] 
│     ├── [email protected] 
│     └─┬ [email protected] 
│       ├─┬ [email protected] 
│       │ └── [email protected] 
│       ├─┬ [email protected] 
│       │ └── [email protected] 
│       ├─┬ [email protected] 
│       │ ├─┬ [email protected] 
│       │ │ └── [email protected] 
│       │ ├── [email protected] 
│       │ ├─┬ [email protected] 
│       │ │ ├── [email protected] 
│       │ │ ├── [email protected] 
│       │ │ ├── [email protected] 
│       │ │ ├── [email protected] 
│       │ │ ├── [email protected] 
│       │ │ ├─┬ [email protected] 
│       │ │ │ ├─┬ [email protected] 
│       │ │ │ │ └── [email protected] 
│       │ │ │ └── [email protected] 
│       │ │ ├─┬ [email protected] 
│       │ │ │ └── [email protected] 
│       │ │ └── [email protected] 
│       │ └── [email protected] 
│       ├─┬ [email protected] 
│       │ ├── [email protected] 
│       │ ├── [email protected] 
│       │ ├── [email protected] 
│       │ └── [email protected] 
│       ├─┬ [email protected] 
│       │ ├── [email protected] 
│       │ ├── [email protected] 
│       │ ├─┬ [email protected] 
│       │ │ └── [email protected] 
│       │ ├── [email protected] 
│       │ ├─┬ [email protected] 
│       │ │ └── [email protected] 
│       │ ├── [email protected] 
│       │ ├── [email protected] 
│       │ ├─┬ [email protected] 
│       │ │ └── [email protected] 
│       │ ├─┬ [email protected] 
│       │ │ ├─┬ [email protected] 
│       │ │ │ ├── [email protected] 
│       │ │ │ ├── [email protected] 
│       │ │ │ ├── [email protected] 
│       │ │ │ └── [email protected] 
│       │ │ ├─┬ [email protected] 
│       │ │ │ └── [email protected] 
│       │ │ ├─┬ [email protected] 
│       │ │ │ ├── [email protected] 
│       │ │ │ ├─┬ [email protected] 
│       │ │ │ │ └── [email protected] 
│       │ │ │ ├── [email protected] 
│       │ │ │ └── [email protected] 
│       │ │ └─┬ [email protected] 
│       │ │   └── [email protected] 
│       │ ├─┬ [email protected] 
│       │ │ ├── [email protected] 
│       │ │ ├── [email protected] 
│       │ │ ├── [email protected] 
│       │ │ └── [email protected] 
│       │ ├─┬ [email protected] 
│       │ │ ├── [email protected] 
│       │ │ ├─┬ [email protected] 
│       │ │ │ ├── [email protected] 
│       │ │ │ ├── [email protected] 
│       │ │ │ └── [email protected] 
│       │ │ └─┬ [email protected] 
│       │ │   ├── [email protected] 
│       │ │   ├── [email protected] 
│       │ │   ├─┬ [email protected] 
│       │ │   │ └── [email protected] 
│       │ │   ├── [email protected] 
│       │ │   ├─┬ [email protected] 
│       │ │   │ └── [email protected] 
│       │ │   ├── [email protected] 
│       │ │   ├── [email protected] 
│       │ │   └── [email protected] 
│       │ ├── [email protected] 
│       │ ├── [email protected] 
│       │ ├── [email protected] 
│       │ ├─┬ [email protected] 
│       │ │ └── [email protected] 
│       │ ├── [email protected] 
│       │ ├── [email protected] 
│       │ ├── [email protected] 
│       │ ├── [email protected] 
│       │ ├── [email protected] 
│       │ └── [email protected] 
│       ├─┬ [email protected] 
│       │ └─┬ [email protected] 
│       │   ├── [email protected] 
│       │   ├── [email protected] 
│       │   ├─┬ [email protected] 
│       │   │ └─┬ [email protected] 
│       │   │   ├── [email protected] 
│       │   │   └── [email protected] 
│       │   └── [email protected] 
│       ├── [email protected] 
│       ├─┬ [email protected] 
│       │ ├── [email protected] 
│       │ ├─┬ [email protected] 
│       │ │ └── [email protected] 
│       │ └── [email protected] 
│       └─┬ [email protected] 
│         ├─┬ [email protected] 
│         │ └── [email protected] 
│         ├── [email protected] 
│         ├─┬ [email protected] 
│         │ └── [email protected] 
│         ├─┬ [email protected] 
│         │ ├── [email protected] 
│         │ ├── [email protected] 
│         │ ├── [email protected] 
│         │ ├── [email protected] 
│         │ ├── [email protected] 
│         │ └── [email protected] 
│         └── [email protected] 
└─┬ [email protected]
  └─┬ [email protected]
    └─┬ [email protected]
      └─┬ [email protected]
        ├── [email protected] 
        ├── [email protected] 
        ├── [email protected] 
        └── [email protected] 

npm WARN [email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN [email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN [email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN [email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN [email protected] requires a peer of @angular/[email protected] but none was installed.

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

I created a github repo for this: https://github.com/thehashrocket/test-project/

I'm just about to run the typings program. i'm going to do a commit after each step.

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

does it work when you serve?

lexcaraig avatar Aug 01 '16 01:08 lexcaraig

let me try. i just ran typings install file:node_modules/angularfire2/firebase3.d.ts --save --global && typings install but haven't gone any further. committed my code.

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

ng serve works so far.

screen shot 2016-07-31 at 7 52 46 pm

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

No errors so far in console.?

lexcaraig avatar Aug 01 '16 01:08 lexcaraig

@lexcaraig should i be doing this?

typings install --save --global es6-promise

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

no errors in console.

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

wait not yet

lexcaraig avatar Aug 01 '16 01:08 lexcaraig

so i should go ahead to step 4. Open angular-cli-build.js.

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

Actually, you don't need to use typings install --save --global es6-promise just add the files because you are not targeting es6 output.

"files": [
    "main.ts",
    "typings.d.ts",
    "node_modules/angularfire2/firebase3.d.ts"
  ]

lexcaraig avatar Aug 01 '16 01:08 lexcaraig

ok, committed the next steps. so far, no errors in ng build, no errors in console.

thehashrocket avatar Aug 01 '16 01:08 thehashrocket

Then i guess you just have to follow the next other steps. I guess it will work now. I hope so. Haha.

lexcaraig avatar Aug 01 '16 02:08 lexcaraig