Error with "ng build && ng serve" following "Installation and Setup" guide
I followed the steps from the installation guide but I receive the below errors:
Build error
The Broccoli Plugin: [BroccoliTypeScriptCompiler] failed with:
SyntaxError: Unexpected token ]
at Object.parse (native)
at BroccoliTypeScriptCompiler._loadTsConfig (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:128:25)
at BroccoliTypeScriptCompiler._createServiceHost (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:163:25)
at BroccoliTypeScriptCompiler.build (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:41:12)
at C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\broccoli-caching-writer\index.js:152:21
at lib$rsvp$$internal$$tryCatch (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1036:16)
at lib$rsvp$$internal$$invokeCallback (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1048:17)
at lib$rsvp$$internal$$publish (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1019:11)
at lib$rsvp$asap$$flush (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1198:9)
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)
The broccoli plugin was instantiated at:
at BroccoliTypeScriptCompiler.Plugin (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\broccoli-plugin\index.js:10:31)
at BroccoliTypeScriptCompiler.CachingWriter [as constructor] (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\broccoli-caching-writer\index.js:21:10)
at BroccoliTypeScriptCompiler (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:27:10)
at Angular2App._getTsTree (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\lib\broccoli\angular2-app.js:331:18)
at Angular2App._buildTree (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\lib\broccoli\angular2-app.js:124:23)
at new Angular2App (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\lib\broccoli\angular2-app.js:53:23)
at module.exports (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\angular-cli-build.js:10:10)
at Class.module.exports.Task.extend.setupBroccoliBuilder (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\ember-cli\lib\models\builder.js:55:19)
at Class.module.exports.Task.extend.init (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\ember-cli\lib\models\builder.js:89:10)
at new Class (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\core-object\core-object.js:18:12)
at Class.module.exports.Task.extend.run (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\ember-cli\lib\tasks\serve.js:15:19)
at C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\ember-cli\lib\commands\serve.js:64:24
at lib$rsvp$$internal$$tryCatch (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1036:16)
at lib$rsvp$$internal$$invokeCallback (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1048:17)
at lib$rsvp$$internal$$publish (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1019:11)
at lib$rsvp$asap$$flush (C:\Users\Marian\Desktop\ng_cli\test_cli_fire\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1198:9)
Files:
src\main.ts
import { BrowserModule } from '@angular/platform-browser';
import { enableProdMode, NgModule } from '@angular/core';
import { <MyApp>, environment } from './app/';
import { AngularFireModule } from '/angularfire2';
const firebaseConfig = {
apiKey: "AIzaSyBofqdUZR8WLKdPsqryQtF1lFxNAdk6JEI",
authDomain: "vital-contact-116013.firebaseapp.com",
databaseURL: "https://vital-contact-116013.firebaseio.com",
storageBucket: "<your-storage-bucket>"
}
@NgModule({
imports: [
BrowserModule,
AngularFireModule.initializeApp(firebaseConfig)
],
declarations: [ MyComponent ],
Bootstrap: [ MyComponent ]
})
export class MyAppModule {}
src\app\app.component.ts
import { Component } from '@angular/core';
import { AngularFire, FirebaseListObservable } from 'angularfire2';
@Component({
moduleId: module.id,
selector: '<my-app>-app',
templateUrl: '<my-app>.component.html',
styleUrls: ['<my-app>.component.css']
})
export class <MyApp>Component {
items: FirebaseListObservable<any[]>;
constructor(af: AngularFire) {
this.items = af.database.list('items');
}
}
src\tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"mapRoot": "/",
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": false,
"outDir": "../dist/",
"rootDir": ".",
"sourceMap": true,
"target": "es5",
"inlineSources": true
},
"files": [
"main.ts",
"typings.d.ts",
"node_modules/angularfire2/firebase3.d.ts",
]
}
typings.json
{
"globalDevDependencies": {
"angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654"
},
"globalDependencies": {
"es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504",
"firebase3": "file:node_modules/angularfire2/firebase3.d.ts"
},
"dependencies": {
"es6-promise": "registry:npm/es6-promise#3.0.0+20160723033700"
}
}
I also tried the path shown here: https://www.youtube.com/watch?v=8E-dueHCd2o but without success
The installation and setup for angularfire2 (08/26/2016) targets a little different project structure from the one which angular CLI creates (08/26/2016)
/src/main.ts
/src/app/app.component.ts
I have the exactly the same problem. I did generate my app using angular-cli.webpack.
I have the same problem, but then i try with login the app run only for Password login and not for Google ora Twitter or Facebook. I did generate my app using angular-cli.webpack.
It works for me when I added the "firebase" on "types" section of tsconfig.json
"types": [
"jasmine",
"firebase"
]
Do not need to upgrade to [email protected], I'm using 1.8.10.
Is this a good solution?
Thanks!
Amazing stuff ... Some face the same worries, the other not , plus differences in the configuration.
For my part :
- I'm under Windows 10
tsc -v: Version 2.0.0npm list: here
Thanks
@paulogr The Firebase typings require TypeScript 2.0+
@GitHubish Can you publish your project to Github for me to take a look at? You have the correct versions installed.
Thank-you for your prompt response. I am still looking but for the moment I do not understand. In fact , I have the impression that strangely tsconfig.json is ignored.
Here are my deposit : https://github.com/GitHubish/angularfire2-test-webpack (all is ok - repo removed)
Reminder I have a mistake with the definition firebase not found : error in the chrome console in the IDE (VS Code) and in the console at the ng build)
Furthermore I have the error "
[ts]
Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.
on app.module.ts and app.component.ts . Strange
Thanks
@GitHubish The experimental thing is something i have a fix for here: http://stackoverflow.com/questions/31737677/vscode-is-it-possible-to-supress-experimental-decorator-warnings/38970591#38970591
@Hojou Ah cool ! Thank you for the tip !
Having the same problem when following the Guide. Problem happened after Step 2 when installing angularfire2. And injecting with
import { AngularFireModule } from 'angularfire2';
Hi @dmastag, I tried the following steps in my machine running os: win32 x64, node: 4.4.7 for using Angular Fire beta4 version. And these steps were successful. 1. Installing Angular-cli fresh: https://github.com/angular/angular-cli/blob/master/WEBPACK_UPDATE.md npm unlink angular-cli npm rm -g angular-cli npm cache clean npm install --global angular-cli@webpack ->[1.0.0-beta.11-webpack.2] ng new projectName
2. Installing AngularFire Beta 4: npm install firebase angularfire2@next --save In package.json change 2.0.0-beta.3-pre2 to 2.0.0-beta.4 And run npm install again
3.In App.module.ts file import {AngularFireModule} from 'angularfire2'; import * as firebase from 'firebase'; const firebaseConfig = { apiKey: "YourKey", authDomain: "YourDomain", databaseURL: "YourURL", storageBucket: "Your Bucket" } Inside NgModule Imports section, add-> AngularFireModule.initializeApp(firebaseConfig)
4. In App.component.ts import { AngularFire, FirebaseListObservable } from 'angularfire2'; Inside AppComponent section, add-> items: FirebaseListObservable any[];//add brackets constructor(af: AngularFire) { this.items = af.database.list('/items'); } 5. Log into Firebase console Change the rules to read Add some sample data under items.
6. In App.component.html
ul li class="text" *ngFor="let item of items | async" {{item.$value}} /li /ul
7. command line npm install -g firebase-tools Firebase init, Select the firebase project created in the Firebase console Create a database rules json file, press enter Public directory is dist Configure as a single page app - N dist/index.html overwrite - N delete dist folder ng build Firebase serve. Firebase deploy -m “comments" Firebase open
For me everything all is ok , the problem with Firebase is set . The concern was resolved by being passed on version 8 of Angularcli-webpack.
@gmanojisaac are you trying to say that it is working with those steps? @GitHubish I am on 1.0.0-beta.11-webpack.8 now. Still no luck. Tried again 2 times today.
I'm having the same issue with the error "Cannot find namespace 'firebase'." in a variety of angulafire2 files. I'm on Typescript 2.0 on global and local.
Let me know if there's anything I can provide to help.
@ashmccallum I've experienced those errors with a completely fresh install using angular-cli webpack. My fix which I got from @paulogr above was to edit src/tsconfig.json and add the lines (since new webpack angular-cli doesn't have the base entry for jasmine)
,
"types": [
"firebase"
]
at the end of the compilerOptions entry after the typeRoots entry like so
{
"compilerOptions": {
"declaration": false,
...
"typeRoots": [
"../node_modules/@types"
],
"types": [
"firebase"
]
}
}
thanks @terencewhitenz that seems to have sorted it for me as I can now see permission errors in the console
I created a repository: https://github.com/sorcamarian/angularfire2-instalation-webpack-fixed-errors
Thank you all!
@gmanojisaac, your instructions were the most appropriate for me.(without point 7)