Closed k1ng440 closed 8 years ago
I have the same problem...
it work when i follow the Troubleshooting. https://github.com/angular/angularfire2/blob/master/docs/1-install-and-setup.md
tsconfig.json:
{ "compilerOptions": { "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": ["es6", "dom"], "mapRoot": "./", "module": "es6", "moduleResolution": "node", "outDir": "../dist/out-tsc", "sourceMap": true, "target": "es5", "typeRoots": [ "../node_modules/@types" ], "types": [ "firebase" ] } }
you added "firebase" to types, right?
it didnt work for me
I don't understand the question. but I just restart the guide to I get it to work. toke some time.
@k1ng440 I'll recommend try the install guide again. you "ng -v" gives angular-cli: 1.0.0-beta.11-webpack.8 , where as angular-cli has got updated. so may be worth un-installing and re-installing angular-cli. Also, I've faced issues on windows system and have seen others also facing different issues on windows, but everything seems to be working fine on linux based system. Just so you know.
I could reproduce this issue. It guess this might be a regression, because it seemed to be fixed in early versions.
I don't know if it's related to angularfire2 or angular-cli
//cc @TheLarkInn @davideast any idea?
angular-cli: local (v1.0.0-beta.14, branch: master)
node: 6.4.0
os: darwin x64
@angular/core: ^2.0.0
angularfire2: ^2.0.0-beta.5
firebase: ^3.4.0
@k1ng440 I'm curious, is the firebase package installed in your root node_modules
(i.e. your-app/node_modules/firebase
), or is it just installed inside your-project/node_modules/angularfire2/node_modules/firebase
?
i have firebase on node_modules/firebase and angularfire2/node_modules/firebase
@k1ng440 thanks. This might be an issue with AF2 still depending on 3.3.0, and TypeScript might not be resolving the types correctly since there are two instances of firebase.
As an experiment, could you delete node_modules/angularfire2/node_modules/firebase
and then see if the problem is solved?
removed and it didn't solve the issue
@alexeagle and I have tracked down the issue. None of our .d.ts files include any imports from firebase
, which is causing node_modules/firebase/firebase.d.ts
never to be loaded. If firebase.d.ts
ever gets loaded, it would add firebase
to the ambient typings and make these errors go away. I'm going to refactor all of our modules to properly import from firebase instead of relying on ambient typings.
In the meantime, you should be able to work around this problem by adding a reference to your project's entry file pointing directly to firebase.d.ts
/// <reference path="node_modules/firebase/firebase.d.ts" />
i tried to add
/// <reference path="node_modules/firebase/firebase.d.ts" />
to main.ts, typings.d.ts and app.module.ts. none of them solves this issue
thanks
Try adding it into "files" list in the tsconfig.json
@k1ng440 is that the right relative path, or does it need some ../
on the front?
@k1ng440 I solved it by either adding
import * as firebase from 'firebase';
or
///
on top of node_modules\angularfire2\angularfire2.d.ts
As mentioned over here -> https://github.com/angular/angularfire2/issues/486#issuecomment-247534422
For non-Windows users this should be solved by adding firebase into the types array of your tsconfig file.
i have both in app.modules.ts and it doesn't work :(
@k1ng440 Try changing the angularfire2.d.ts file directly like I mentioned
Hi, Yes i have used ../ but still doesn't help me
/// <reference path="../../node_modules/firebase/firebase.d.ts" />
@jeffbcross Hopefully, this should remove the need to add firebase entry in types arrays in 'src/tsconfig.json' ?
@mukesh51 yep!
Hi, is this fixed in the npm package?
@csotomon yes
dont add to tsconfig.json and you should be fine
In mac OS X works perfect, but in Windows 10 dont.
C:\proyectos\testFirebase>ng serve \ NG Live Development Server is running on http://localhost:4200. ** 6541ms building modules 31ms sealing 0ms optimizing 0ms basic module optimization 94ms module optimization 0ms advanced module optimization 16ms basic chunk optimization 0ms chunk optimization 0ms advanced chunk optimization 0ms module and chunk tree optimization 125ms module reviving 0ms module order optimization 0ms module id optimization 0ms chunk reviving 0ms chunk order optimization 15ms chunk id optimization 63ms hashing 0ms module assets processing 140ms chunk assets processing 0ms additional chunk assets processing 0ms recording 0ms additional asset processing 1860ms chunk asset optimization 1375ms asset optimization 47ms emitting Hash: 2e01e12af9286806d79f Version: webpack 2.1.0-beta.22 Time: 10322ms Asset Size Chunks Chunk Names main.bundle.js 3.27 MB 0, 2 [emitted] main styles.bundle.js 10.2 kB 1, 2 [emitted] styles inline.js 5.53 kB 2 [emitted] inline main.map 3.4 MB 0, 2 [emitted] main styles.map 14 kB 1, 2 [emitted] styles inline.map 5.59 kB 2 [emitted] inline index.html 479 bytes [emitted] assets/.npmignore 0 bytes [emitted]
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\angularfire2.d.ts:13:65 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\angularfire2.d.ts:15:45 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth.d.ts:9:39 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth.d.ts:10:51 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth.d.ts:10:91 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth.d.ts:11:50 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth.d.ts:11:118 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth.d.ts:14:55 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:6:81 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:8:48 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:13:45 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:40:10 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:42:13 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:43:13 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:44:14 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:45:15 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:48:54 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:48:84 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\firebase_sdk_auth_backend.d.ts:5:13 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\firebase_sdk_auth_backend.d.ts:6:24 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\firebase_sdk_auth_backend.d.ts:14:72 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\firebase_sdk_auth_backend.d.ts:16:35 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\firebase_sdk_auth_backend.d.ts:17:36 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\database.d.ts:8:28 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\database.d.ts:9:30 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_factory.d.ts:3:73 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_factory.d.ts:3:103 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:6:49 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:6:79 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:8:10 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:8:40 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:9:22 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:9:52 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:11:20 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:12:52 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:13:38 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:14:82 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_object_factory.d.ts:3:75 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_object_observable.d.ts:7:101 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_object_observable.d.ts:9:21 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_object_observable.d.ts:10:27 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_object_observable.d.ts:11:14 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\interfaces.d.ts:9:22 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\interfaces.d.ts:10:25 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\interfaces.d.ts:11:25 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\interfaces.d.ts:12:34 Cannot find namespace 'firebase'.
ERROR in [default] C:\proyectos\testFirebase\src\typings.d.ts:6:12 Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire', but here has type 'any'.
ERROR in [default] C:\proyectos\testFirebase\src\typings.d.ts:7:12 Subsequent variable declarations must have the same type. Variable 'module' must be of type 'NodeModule', but here has type 'any'. Child html-webpack-plugin for "index.html": Asset Size Chunks Chunk Names index.html 2.81 kB 0 webpack: bundle is now VALID.
@csotomon Even though errors are thrown on Windows 10, the connectivity with Firebase should work as expected. I did raise an issue sometime back to highlight this behaviour #569
@davideast FYI.
@mukesh51 is true, the connectivity works. Thank U.
to solve this issue just copy firebase folder from /node_module to /node_module/@types it will remove all those errors...i have tried it and it worked for me finally
Just ran into this on windows myself. There's 2 steps to fix it atm:
"firebase"
from the types
array in tsconfig.json
/// <reference path="../node_modules/firebase/firebase.d.ts" />
to your src/typings.d.ts
. Verify this file exists though, if it doesn't you probably need to add firebase
as a dependency.Tried adding
import * as firebase from 'firebase';
and got this these errors instead:
ERROR in [default] C:\Users\lednh\Documents\ng2\ng2-simple-todos\node_modules\@types\firebase\index.d.ts:326:1
Duplicate identifier 'export='.
ERROR in [default] C:\Users\lednh\Documents\ng2\ng2-simple-todos\node_modules\firebase\firebase.d.ts:405:2
Duplicate identifier 'export='.
@lednhatkhanh try removing the import * as firebase from 'firebase'; from angularfire.d.ts and then restart ng serve
@mukesh51 Removing all the "import * as firebase from 'firebase';" added to commit/c3a954c worked for me.
I think a better idea is to delete firebase from @types folder.
In my case, just removing firebase
from types
array in tsconfig.json did not fix this issue, but also I had to remove import 'firebase'
from vendor.ts file.
Which reminds me an issue I've previously reported #521
npm install --save angularfire2 firebase
In tsconfig.json add:
"files": [
"../node_modules/firebase/firebase.d.ts"
]
In anglar-cli.json file add:
"scripts": [
"../node_modules/firebase/firebase.js",
]
And in typings.d.ts file add:
declare var System: any;
declare var require: any;
declare var module: any;
Close the server and re-run ng serve
There is no need to install @types/firebase
and add firebase
to types
array
Upgrade from Angular 2.RC4 to final with Angular-CLI
I tried some of the workarounds listed in the answers but I am not able to solve the problem. I still get
"ERROR in [default]
Cannot find type definition file for 'firebase"
while compiling with Webpack (even if the app starts and works fine).
I am working with:
package.json is { "name": "final-project", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { "start": "ng serve", "lint": "tslint \"src/*/.ts\"", "test": "ng test", "pree2e": "webdriver-manager update", "e2e": "protractor", "populate-db": "./node_modules/.bin/ts-node ./populate-db.ts", "batch-server": "./node_modules/.bin/ts-node ./batch-server.ts" }, "private": true, "dependencies": { "@angular/common": "2.0.1", "@angular/compiler": "2.0.1", "@angular/core": "2.0.1", "@angular/forms": "2.0.1", "@angular/http": "2.0.1", "@angular/platform-browser": "2.0.1", "@angular/platform-browser-dynamic": "2.0.1", "@angular/router": "3.0.0", "@types/lodash": "^4.14.36", "@types/request": "0.0.30", "angular2-firebase": "^0.7.3", "angularfire2": "^2.0.0-beta.4", "core-js": "^2.4.0", "firebase-queue": "^1.5.0", "lodash": "^4.15.0", "rxjs": "5.0.0-beta.12", "ts-helpers": "^1.1.1", "zone.js": "^0.6.21" }, "devDependencies": { "@types/jasmine": "^2.2.30", "angular-cli": "1.0.0-beta.16", "codelyzer": "~0.0.26", "jasmine-core": "2.4.1", "jasmine-spec-reporter": "2.5.0", "karma": "0.13.22", "karma-chrome-launcher": "0.2.3", "karma-jasmine": "0.3.8", "karma-remap-istanbul": "^0.2.1", "protractor": "4.0.3", "ts-node": "^1.2.1", "tslint": "3.13.0", "typescript": "^2.0.2" } }
tsconfig.json is
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
],
"types": [
"node",
"firebase"
]
}
}
typings.d.ts is
// Typings reference file, see links for more information
// https://github.com/typings/typings
// https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html
declare var System: any;
@EnricoPicci the fix should be in beta.6. Are you sure that is being used?
I removed 'firebase' from the "types" of typings.d.ts and the error disappeared. This was already suggested as a solution in this thread but, for reasons which are not clear to me, it did not work before in my case. Thanks for the support
Had the same error after upgrading nodejs on Windows 10 to v.8.9.3. Using Angulafire v.5.0.0-rc.4
Fixed it by removing
import * as firebase from 'firebase/app';
from
node_modules\angularfire2\firebase.app.module.d.ts
@timeens ,
I am stiill facing some issue after removing
import * as firebase from 'firebase/app';
from file you have suggested..
Here is error:
ERROR in node_modules/angularfire2/firebase.app.module.d.ts(4,45): error TS2503: Cannot find namespace 'fir node_modules/angularfire2/firebase.app.module.d.ts(7,17): error TS2503: Cannot find namespace 'firebase'. node_modules/angularfire2/firebase.app.module.d.ts(8,21): error TS2503: Cannot find namespace 'firebase'. node_modules/angularfire2/firebase.app.module.d.ts(9,22): error TS2503: Cannot find namespace 'firebase'. node_modules/angularfire2/firebase.app.module.d.ts(10,20): error TS2503: Cannot find namespace 'firebase'. node_modules/angularfire2/firebase.app.module.d.ts(12,22): error TS2503: Cannot find namespace 'firebase'.
Node Version: v8.4.0 Angular cli : Angular CLI: 1.6.1 Node: 8.4.0 OS: win32 x64 Angular: 5.1.1
Here is the dependencies
"dependencies": { "@angular/animations": "^5.0.0", "@angular/common": "^5.0.0", "@angular/compiler": "^5.0.0", "@angular/core": "^5.0.0", "@angular/forms": "^5.0.0", "@angular/http": "^5.0.0", "@angular/platform-browser": "^5.0.0", "@angular/platform-browser-dynamic": "^5.0.0", "@angular/router": "^5.0.0", "angularfire2": "^5.0.0-rc.5-next", "bootstrap": "^4.0.0-beta.2", "core-js": "^2.4.1", "firebase": "^4.8.1", "font-awesome": "^4.7.0", "jquery": "^3.2.1", "rxjs": "^5.5.2", "zone.js": "^0.8.14" }, "devDependencies": { "@angular/cli": "1.6.1", "@angular/compiler-cli": "^5.0.0", "@angular/language-service": "^5.0.0", "@types/firebase": "^2.4.32", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "codelyzer": "^4.0.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "ts-node": "~3.2.0", "tslint": "~5.7.0", "typescript": "~2.4.2" }
Can you guys' please help me out with this. I have tried all possible solution suggested in all the issue on github and also updated the angular cli and created new project as well still facing same issue.
Thank you in adavance.
@meanMonk,
I had the same issue last night, I was able to resolve it by rolling the firebase dependency back to 4.6.0. I didn’t get to look into the root cause of the differences between 4.6.0 definitions and 4.8.1 definitions, but this definitely solved it for me.
Thank you very much @meanMonk , you saved my time, faced the same issue after upgrading ionic2 project. resolved by rolling the firebase dependency back to 4.6.0
@giannico , Can you please share the version of angularfire2 which you are using in your project as well?
Thank you, @giannico . Issue resolved now. I really appreciate your help.
@giannico Thanks. I changed 4.8.0 to 4.6.0 in package.json and run "npm install" => Now it working.
@huuquyasb what about npm exact option?
npm i -E firebase@4.8.0
@giannico I spent like half the day battling this! At least it got me to update most of my packages in the process... THANKS!
I hope they get things fixed up. Hate to leave a package a few versions back.
I don't see the need to go back to 4.6.0
. Like @nueko said, 4.8.0
works as well.
I have tried everything on this thread: newest version of everything angular here: i want to deploy. ERROR in node_modules/angularfire2/firebase.app.module.d.ts(5,45): error TS2503: Cannot find namespace 'firebase'. node_modules/@firebase/database/dist/esm/src/core/AuthTokenProvider.d.ts(17,39): error TS2307: Cannot find module '@firebase/app-types/private'. node_modules/angularfire2/database/interfaces.d.ts(3,50): error TS2503: Cannot find namespace 'firebase'. node_modules/angularfire2/database/database.d.ts(7,15): error TS2503: Cannot find namespace 'database'. node_modules/angularfire2/database/list/state-changes.d.ts(7,113): error TS2503: Cannot find namespace 'database'. node_modules/angularfire2/database/list/audit-trail.d.ts(7,133): error TS2503: Cannot find namespace 'database'.
4 weeks ago this exact same setup worked like a charm in atom. now switched to vscode.
@NilsNaegele have you tried to delete the node_modules
directory? or further also delete the .lock
file
then run
npm install
// then
npm install --save-exact firebase
// or
yarn
// then
yarn add -E firebase
redid everything and now it works. deleted the .lock file. @nueko thanks.
Nothing worked but going back to "firebase":"4.6.0" worked
Hello, I have tried every possible solution to fix this issue but none helps remove this error message.
tsconfig.json
packages.json