Unable to init new firebase project from console - node.js

I'm trying to host my webapp on firebase and am currently running into this issue:
My order of operations:
(in root) > npm install -g firebase-tools
> firebase login
> $ npm run build
> cd dist
> firebase init iq18
> (select my desired app in FB dropdown)
> returns: Error: An unexpected error has occurred.
No matter what I try, after running init from my /dist directory, I can not get it to actually deploy to firebase. Full error from the logs:
[info]
=== Project Setup
[info]
[info] First, let's associate this project directory with a Firebase project.
[info] You can create multiple project aliases by running firebase use --add,
[info] but for now we'll just set up a default project.
[info]
[debug] [2018-06-04T19:03:39.456Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects
Mon Jun 04 2018 15:03:39 GMT-0400 (EDT)
[debug] [2018-06-04T19:03:39.812Z] <<< HTTP RESPONSE 200
[info]
=== Iq17 Setup
[debug] [2018-06-04T19:03:42.715Z] TypeError: features[nextFeature] is not a function
at init (/usr/local/lib/node_modules/firebase-tools/lib/init/index.js:13:49)
at /usr/local/lib/node_modules/firebase-tools/lib/init/index.js:14:14
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
[error]
[error] Error: An unexpected error has occurred.
Things I've tried:
Deleted my /dist directory and rebuilt the app
Logged out of firebase and relogged in
Deleted the placeholder app from firebase account
Not quite sure what else I can do to fix this deploy issue.

Related

A locally build NPM package - generated by the openapi-generator - does not seem to export the API, although it's available

I created a REST service interface definition with one very simple GET endpoint using OpenAPI 3.
(There is a minified version of that interface in the spoiler.)
{"openapi":"3.0.3","info":{"title":"Identity Cache API Definition","version":"1.0"},"tags":[{"name":"identity-cache"}],"paths":{"/{identityId}/data":{"get":{"tags":["identity-cache"],"summary":"Returns data.","operationId":"getIdentityData","parameters":[{"name":"identityId","in":"path","description":"The identity ID.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The identity data.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdentityData"}}}}}}}},"components":{"schemas":{"IdentityData":{"type":"object","required":["identityId"],"properties":{"identityId":{"type":"string"}}}}}}
Then I generated the typescript-fetch source code with the openapi-generator:
openapi-generator-cli generate -i ../identity-cache-api.yaml -o ./ -g typescript-fetch \
--additional-properties=supportsES6=true,typescriptThreePlus=true,npmVersion=1.0.0,npmName=identity-cache-fetch
After that I built the generated npm package with Node.js v14.7.0 using npm:
npm run build
And finally I added the built package locally to my project with npm install. Here is the added line in the package.json:
"identity-cache-fetch": "file:../identity-cache-npm-package",
Seems good, Visual Studio Code recognizes the new package and let me use it:
import { Configuration, IdentityCacheApi } from "identity-cache-fetch";
const identityCacheApi = new IdentityCacheApi(new Configuration({ basePath: import.meta.env.VITE_BACKEND_URL }));
However the build fails with: vite build
This error arises:
[INFO] error during build:
[INFO] Error: 'IdentityCacheApi' is not exported by ../identity-cache-npm-package/dist/index.js, imported by src/services/service.ts
[INFO] at error (../frontend/node_modules/rollup/dist/shared/rollup.js:160:30)
[INFO] at Module.error (../frontend/node_modules/rollup/dist/shared/rollup.js:12438:16)
[INFO] at Module.traceVariable (../frontend/node_modules/rollup/dist/shared/rollup.js:12808:29)
[INFO] at ModuleScope.findVariable (../frontend/node_modules/rollup/dist/shared/rollup.js:11601:39)
[INFO] at Identifier.bind (../frontend/node_modules/rollup/dist/shared/rollup.js:6479:40)
[INFO] at NewExpression.bind (../frontend/node_modules/rollup/dist/shared/rollup.js:5087:23)
[INFO] at VariableDeclarator.bind (../frontend/node_modules/rollup/dist/shared/rollup.js:5087:23)
[INFO] at VariableDeclaration.bind (../frontend/node_modules/rollup/dist/shared/rollup.js:5083:31)
[INFO] at Program.bind (../frontend/node_modules/rollup/dist/shared/rollup.js:5083:31)
[INFO] at Module.bindReferences (../frontend/node_modules/rollup/dist/shared/rollup.js:12434:18)
[INFO] npm ERR! code ELIFECYCLE
[INFO] npm ERR! errno 1
The index.js seems good. For simplicity, I'm only posting the TypeScript code of the uncompiled index.ts.
/* tslint:disable */
/* eslint-disable */
export * from './runtime';
export * from './apis';
export * from './models';
What am I missing?
Or is it a bug in the openapi-generator or vite?
It's an rollup issue.
By adding an ESM (ECMAScript Module) to the generated code the project finally builds.

Firebase login throws Error: spawn cmd ENOENT in NodeJS

I am trying to set up my Firebase TypeScript application on another system. When I execute firebase login, it throws the following exception:
[debug] [2020-07-10T12:35:28.031Z] ----------------------------------------------------------------------
[debug] [2020-07-10T12:35:28.034Z] Command: C:\Program Files\nodejs\node.exe C:\Users\gp\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js login
[debug] [2020-07-10T12:35:28.034Z] CLI Version: 8.5.0
[debug] [2020-07-10T12:35:28.034Z] Platform: win32
[debug] [2020-07-10T12:35:28.035Z] Node Version: v12.18.2
[debug] [2020-07-10T12:35:28.036Z] Time: Fri Jul 10 2020 18:05:28 GMT+0530 (India Standard Time)
[debug] [2020-07-10T12:35:28.036Z] ----------------------------------------------------------------------
[debug] [2020-07-10T12:35:28.037Z]
[info] i Firebase optionally collects CLI usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you.
[info] i To change your data collection preference at any time, run `firebase logout` and log in again.
[info]
[info] Visit this URL on this device to log in:
[info] https://accounts.google.com/o/oauth2/auth?client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&scope=email%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloudplatformprojects.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffirebase%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&response_type=code&state=3839&redirect_uri=http%3A%2F%2Flocalhost%3A
[info]
[info] Waiting for authentication...
[debug] [2020-07-10T12:57:25.170Z] Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
[error]
[error] Error: An unexpected error has occurred.
On the new system, I am using the following software:
node v12.18.2
npm v6.14.5
On the old system, I was using the following software:
node v10.16.3
npm v6.12.0
I have also tried the following:
executing npm install -g firebase-tools#latest
executing all steps in a separate cmd running as admin.
Everything was working perfectly in my old workspace.
Fixed the issue by adding 'C:\Windows\System32' in my environment variable.

Has anyone gone through the cloud functions tutorial recently?

I am having the hardest of times just trying to get through the cloud functions tutorial here. Every time I try to do firebase deploy --only functions, I always get an error. My firebase-debug.log looks like this 👉🏾
[debug] [2020-05-05T23:45:15.510Z] ----------------------------------------------------------------------
[debug] [2020-05-05T23:45:15.514Z] Command: /usr/local/bin/node /usr/local/bin/firebase deploy --only functions
[debug] [2020-05-05T23:45:15.515Z] CLI Version: 6.3.0
[debug] [2020-05-05T23:45:15.515Z] Platform: darwin
[debug] [2020-05-05T23:45:15.515Z] Node Version: v8.17.0
[debug] [2020-05-05T23:45:15.515Z] Time: Tue May 05 2020 19:45:15 GMT-0400 (EDT)
[debug] [2020-05-05T23:45:15.515Z] ----------------------------------------------------------------------
[debug]
[debug] [2020-05-05T23:45:15.532Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2020-05-05T23:45:15.533Z] > authorizing via signed-in user
[debug] [2020-05-05T23:45:15.533Z] [iam] checking project cloud-functions-demo-5b1c8 for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[debug] [2020-05-05T23:45:15.535Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2020-05-05T23:45:15.535Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token
<request body omitted>
[debug] [2020-05-05T23:45:15.672Z] <<< HTTP RESPONSE 200
[debug] [2020-05-05T23:45:15.684Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/cloud-functions-demo-5b1c8:testIamPermissions
[debug] [2020-05-05T23:45:15.818Z] <<< HTTP RESPONSE 200
[debug] [2020-05-05T23:45:17.852Z] TypeError: Cannot read property 'wanted' of undefined
at /usr/local/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:37:51
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
[error]
[error] Error: An unexpected error has occurred.
[debug] [2020-05-05T23:45:48.671Z] ----------------------------------------------------------------------
[debug] [2020-05-05T23:45:48.674Z] Command: /usr/local/bin/node /usr/local/bin/firebase deploy --only functions
[debug] [2020-05-05T23:45:48.675Z] CLI Version: 6.3.0
[debug] [2020-05-05T23:45:48.675Z] Platform: darwin
[debug] [2020-05-05T23:45:48.675Z] Node Version: v8.17.0
[debug] [2020-05-05T23:45:48.675Z] Time: Tue May 05 2020 19:45:48 GMT-0400 (EDT)
[debug] [2020-05-05T23:45:48.676Z] ----------------------------------------------------------------------
[debug]
[debug] [2020-05-05T23:45:48.690Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2020-05-05T23:45:48.690Z] > authorizing via signed-in user
[debug] [2020-05-05T23:45:48.690Z] [iam] checking project cloud-functions-demo-5b1c8 for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[debug] [2020-05-05T23:45:48.693Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/cloud-functions-demo-5b1c8:testIamPermissions
[debug] [2020-05-05T23:45:48.887Z] <<< HTTP RESPONSE 200
[debug] [2020-05-05T23:45:50.700Z] TypeError: Cannot read property 'wanted' of undefined
at /usr/local/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:37:51
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
[error]
[error] Error: An unexpected error has occurred.
I would appreciate any help in this area! I have already tried deleting the functions directory and just running firebase deploy but that has been unsuccessful. I have also tried downgrading node.js and npm to 6.9.2 (using n) but that hasn't worked either. Any help would be greatly appreciated!
You should bump your cli version from 6.3.0 to 7.1.0 or above, as it fixes the issue reported here https://github.com/firebase/firebase-tools/issues/1469
Maybe also double check that your cloud functions package is up to date? It's hard to tell from your question what your current version is.
So, I went down the rabbit hole online for a few days and finally found a solution through a combination of stackoverflow and GitHub.
First, do the instructions outlined here
Then, lastly do this in your terminal: alias firebase="`npm config get prefix`/bin/firebase" which was from this closed GitHub issue
Hope it helps someone!

Firebase hosting : unable to verify first certificate

Is anybody here to help me with this ?
Whenever I try to initiate firebase hosting, I get this error.
Error is "Server Error. unable to verify the first certificate".
Two months passed but I haven't got the solution. Even I contacted Firebase Support Team, but they didn't help.
Please, help me.
Firebase-debug.log :
You're about to initialize a Firebase project in this directory:
F:\cv_web\build
[info]
=== Project Setup
[info]
[info] First, let's associate this project directory with a Firebase project.
[info] You can create multiple project aliases by running firebase use --add,
[info] but for now we'll just set up a default project.
[info]
[debug] [2019-12-04T21:11:12.162Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects?pageSize=100
[debug] [2019-12-04T21:11:13.569Z] <<< HTTP RESPONSE 200
[info] i Using project abhijeetbharti-b42e1 (abhijeetbharti)
[info]
=== Hosting Setup
[info]
[info] Your public directory is the folder (relative to your project directory) that
[info] will contain Hosting assets to be uploaded with firebase deploy. If you
[info] have a build process for your assets, use your build's output directory.
[info]
[info] + Wrote build/404.html
[debug] [2019-12-04T21:11:25.792Z] >>> HTTP REQUEST GET https://www.gstatic.com/firebasejs/releases.json
[debug] [2019-12-04T21:11:27.490Z] Error: unable to verify the first certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1321:34)
at TLSSocket.emit (events.js:210:5)
at TLSSocket.EventEmitter.emit (domain.js:478:20)
at TLSSocket._finishInit (_tls_wrap.js:794:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:608:12)
[error]
[error] Error: Server Error. unable to verify the first certificate

Firebase Web Init Error File Already Exists

I've installed Node.js, npm, and firebase-tools. I want to deploy a web app using Firebase hosting. I follow the documentation and do the commands as shown, but I get an unexpected error. I've posted the firebase debug log. How do I fix this?
[debug] [2019-04-20T21:08:12.230Z] ----------------------------------------------------------------------
[debug] [2019-04-20T21:08:12.233Z] Command: C:\Program Files\nodejs\node.exe C:\Users\Cameron\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js init
[debug] [2019-04-20T21:08:12.233Z] CLI Version: 6.7.0
[debug] [2019-04-20T21:08:12.233Z] Platform: win32
[debug] [2019-04-20T21:08:12.233Z] Node Version: v11.14.0
[debug] [2019-04-20T21:08:12.234Z] Time: Sat Apr 20 2019 17:08:12 GMT-0400 (Eastern Daylight Time)
[debug] [2019-04-20T21:08:12.234Z] ----------------------------------------------------------------------
[debug]
[debug] [2019-04-20T21:08:12.241Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2019-04-20T21:08:12.242Z] > authorizing via signed-in user
[info]
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
C:\Users\Cameron
Before we get started, keep in mind:
* You are initializing your home directory as a Firebase project
[info]
=== Project Setup
[info]
[info] First, let's associate this project directory with a Firebase project.
[info] You can create multiple project aliases by running firebase use --add,
[info] but for now we'll just set up a default project.
[info]
[debug] [2019-04-20T21:08:16.637Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2019-04-20T21:08:16.638Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token
<request body omitted>
[debug] [2019-04-20T21:08:16.846Z] <<< HTTP RESPONSE 200
[debug] [2019-04-20T21:08:16.878Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects?page_size=100
[debug] [2019-04-20T21:08:17.215Z] <<< HTTP RESPONSE 200
[info] i Using project autoretarb (autoretarb)
[info]
=== Hosting Setup
[info]
[info] Your public directory is the folder (relative to your project directory) that
[info] will contain Hosting assets to be uploaded with firebase deploy. If you
[info] have a build process for your assets, use your build's output directory.
[info]
[debug] [2019-04-20T21:08:33.318Z] Error: EEXIST: file already exists, mkdir 'C:\Users\Cameron'
at Object.mkdirSync (fs.js:773:3)
at mkdirsSync (C:\Users\Cameron\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:22:9)
at mkdirsSync (C:\Users\Cameron\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:27:16)
at mkdirsSync (C:\Users\Cameron\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:28:9)
at mkdirsSync (C:\Users\Cameron\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:28:9)
at mkdirsSync (C:\Users\Cameron\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:28:9)
at mkdirsSync (C:\Users\Cameron\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:28:9)
at mkdirsSync (C:\Users\Cameron\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:28:9)
at mkdirsSync (C:\Users\Cameron\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:28:9)
at mkdirsSync (C:\Users\Cameron\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:28:9)
[error]
[error] Error: An unexpected error has occurred.
First of all notice the warning near the top:
Before we get started, keep in mind:
You are initializing your home directory as a Firebase project
Please be certain that you want to use your home directory as a project root. This generally is not a really good idea. It will definitely cause problems later if you want to create other projects in your home directory. Instead, I suggest you create a new directory and run firebase init from there. The CLI will want to create bunch of other files and dirs there.
Now, notice the prompt where you got the error:
Your public directory is the folder (relative to your project
directory) that will contain Hosting assets to be uploaded with
firebase deploy. If you have a build process for your assets,
use your build's output directory.
It specifically says relative to your project directory, but you gave it an absolute path "C:\Biz Drive\admin_public".
It's better to allow the Firebase CLI to create the public folder at its default location within the project folder, unless you know you have a very specific need otherwise. In order to get started, I suggest just taking the defaults, then modifying them later in firebase.json afterward.
If you are using Windows
I faced same error then I just run command prompt as admin then problem solved.

Resources