Has anyone gone through the cloud functions tutorial recently? - node.js

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!

Related

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.

Unable to import AWS infrastructure configurartion using terraformer

I am trying to import existing AWS infra configuration using google's terraformer and I am unsuccessful due to AWS provider authentication problem. My AWS credentials are MFA enabled and hence i have to use session token. I failed to find options to enable terraformer to use aws session token params.
Here is the debug logs for the terraformer program. Could someone help me with this please. The below is generating empty tf files and states.
Master $ terraformer import aws --resources=vpc --regions=eu-central-1 -c -v
2020/06/02 23:17:53 aws importing region eu-central-1
2020/06/02 23:17:53 aws importing... vpc
2020-06-02T23:17:53.525+0530 [INFO] plugin: configuring client automatic mTLS
2020-06-02T23:17:53.593+0530 [DEBUG] plugin: starting plugin: path=.terraform/plugins/darwin_amd64/terraform-provider-aws_v2.64.0_x4 args=[.terraform/plugins/darwin_amd64/terraform-provider-aws_v2.64.0_x4]
2020-06-02T23:17:53.597+0530 [DEBUG] plugin: plugin started: path=.terraform/plugins/darwin_amd64/terraform-provider-aws_v2.64.0_x4 pid=47500
2020-06-02T23:17:53.597+0530 [DEBUG] plugin: waiting for RPC address: path=.terraform/plugins/darwin_amd64/terraform-provider-aws_v2.64.0_x4
2020-06-02T23:17:54.254+0530 [INFO] plugin.terraform-provider-aws_v2.64.0_x4: configuring server automatic mTLS: timestamp=2020-06-02T23:17:54.253+0530
2020-06-02T23:17:54.329+0530 [DEBUG] plugin: using plugin: version=5
2020-06-02T23:17:54.329+0530 [DEBUG] plugin.terraform-provider-aws_v2.64.0_x4: plugin address: network=unix address=/var/folders/jj/2w6phyrs1fj68ks7ry714z000000gn/T/plugin871781403 timestamp=2020-06-02T23:17:54.328+0530
2020-06-02T23:17:54.586+0530 [DEBUG] plugin.terraform-provider-aws_v2.64.0_x4: 2020/06/02 23:17:54 [INFO] No assume_role block read from configuration
2020-06-02T23:17:54.586+0530 [DEBUG] plugin.terraform-provider-aws_v2.64.0_x4: 2020/06/02 23:17:54 [INFO] Building AWS auth structure
2020-06-02T23:17:54.586+0530 [DEBUG] plugin.terraform-provider-aws_v2.64.0_x4: 2020/06/02 23:17:54 [INFO] Setting AWS metadata API timeout to 100ms
2020-06-02T23:17:56.003+0530 [DEBUG] plugin.terraform-provider-aws_v2.64.0_x4: 2020/06/02 23:17:55 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2020-06-02T23:17:56.010+0530 [DEBUG] plugin.terraform-provider-aws_v2.64.0_x4: 2020/06/02 23:17:56 [INFO] AWS Auth provider used: "EnvProvider"
2020-06-02T23:17:56.013+0530 [DEBUG] plugin.terraform-provider-aws_v2.64.0_x4: 2020/06/02 23:17:56 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2020-06-02T23:17:57.577+0530 [DEBUG] plugin.terraform-provider-aws_v2.64.0_x4: 2020/06/02 23:17:57 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2020-06-02T23:17:59.652+0530 [DEBUG] plugin: plugin process exited: path=.terraform/plugins/darwin_amd64/terraform-provider-aws_v2.64.0_x4 pid=47500
2020-06-02T23:17:59.652+0530 [DEBUG] plugin: plugin exited
2020/06/02 23:17:59 aws Connecting....
2020/06/02 23:17:59 aws save vpc
2020/06/02 23:17:59 aws save tfstate for vpc
I managed to resolve the problem by explicitily setting the environment variable AWS_SHARED_CREDENTIALS_FILE=~/.aws/credential
Without the above additional env my setup failed.

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

Unable to init new firebase project from console

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.

Chocolatey Installation of Visual Studio Pro 2012 is failing

I'm using Chocolatey to install Visual Studio 2012 Professional
> cinst visualstudio2012professional
In my Chocolatey logs, I'm seeing that the install succeeded.
[DEBUG] Running 'Delete-ExistingErrorLog' for VisualStudio2012Professional
[DEBUG] Looking for failure log at 'C:\Users\Chase\AppData\Local\Temp\chocolatey\VisualStudio2012Professional\failure.log'
[DEBUG] Found the failure log. Deleting it...
[DEBUG] Running 'Run-ChocolateyPS1' for VisualStudio2012Professional with packageFolder:'C:\chocolatey\lib\VisualStudio2012Professional.11.0.1', action: 'install'
[DEBUG] __ PowerShell install (chocolateyinstall.ps1) __
[DEBUG] Looking for chocolateyinstall.ps1 in folder 'C:\chocolatey\lib\VisualStudio2012Professional.11.0.1'. If chocolateyinstall.ps1 is found, it will be run.
[DEBUG] Action file is 'ChocolateyInstall.ps1'
[DEBUG] Running 'C:\chocolatey\lib\VisualStudio2012Professional.11.0.1\Tools\ChocolateyInstall.ps1'
[DEBUG] Running 'Install-ChocolateyPackage' for VisualStudio2012Professional with url:'http://go.microsoft.com/?linkid=9810233', args: '/Passive /NoRestart /AdminFile C:\chocolatey\lib\VisualStudio2012Professional.11.0.1\Tools\AdminDeployment.xml /Log C:\Users\Chase\AppData\Local\Temp\vs.log'
[DEBUG] Running 'Get-ChocolateyWebFile' for VisualStudio2012Professional with url:'http://go.microsoft.com/?linkid=9810233', fileFullPath:'C:\Users\Chase\AppData\Local\Temp\chocolatey\VisualStudio2012Professional\VisualStudio2012ProfessionalInstall.exe',and url64bit:'http://go.microsoft.com/?linkid=9810233'
[DEBUG] Processor width is 64.
Downloading VisualStudio2012Professional (http://go.microsoft.com/?linkid=9810233) to C:\Users\Chase\AppData\Local\Temp\chocolatey\VisualStudio2012Professional\VisualStudio2012ProfessionalInstall.exe
[DEBUG] Running 'Get-WebFile' for C:\Users\Chase\AppData\Local\Temp\chocolatey\VisualStudio2012Professional\VisualStudio2012ProfessionalInstall.exe with url:'http://go.microsoft.com/?linkid=9810233', userAgent: 'chocolatey command line'
[DEBUG] Setting the UserAgent to 'chocolatey command line'
[DEBUG] Running 'Install-ChocolateyInstallPackage' for VisualStudio2012Professional with file:'C:\Users\Chase\AppData\Local\Temp\chocolatey\VisualStudio2012Professional\VisualStudio2012ProfessionalInstall.exe', args: '/Passive /NoRestart /AdminFile C:\chocolatey\lib\VisualStudio2012Professional.11.0.1\Tools\AdminDeployment.xml /Log C:\Users\Chase\AppData\Local\Temp\vs.log'
Installing VisualStudio2012Professional...
[DEBUG] Running 'Start-ChocolateyProcessAsAdmin' with exeToRun:'C:\Users\Chase\AppData\Local\Temp\chocolatey\VisualStudio2012Professional\VisualStudio2012ProfessionalInstall.exe', statements: '/Passive /NoRestart /AdminFile C:\chocolatey\lib\VisualStudio2012Professional.11.0.1\Tools\AdminDeployment.xml /Log C:\Users\Chase\AppData\Local\Temp\vs.log '
Elevating Permissions and running C:\Users\Chase\AppData\Local\Temp\chocolatey\VisualStudio2012Professional\VisualStudio2012ProfessionalInstall.exe /Passive /NoRestart /AdminFile C:\chocolatey\lib\VisualStudio2012Professional.11.0.1\Tools\AdminDeployment.xml /Log C:\Users\Chase\AppData\Local\Temp\vs.log . This may take awhile, depending on the statements.
[DEBUG] Finishing 'Start-ChocolateyProcessAsAdmin'
VisualStudio2012Professional has been installed.
VisualStudio2012Professional has finished succesfully! The chocolatey gods have answered your request!
[DEBUG] Running 'Get-ChocolateyBins' for C:\chocolatey\lib\VisualStudio2012Professional.11.0.1
[DEBUG] __ Executable Links (*.exe) __
[DEBUG] Looking for executables in folder: C:\chocolatey\lib\VisualStudio2012Professional.11.0.1
Adding batch files for any executables found to a location on PATH. In other words the executable will be available from ANY command line/powershell prompt.
[DEBUG] There are no executables (that are not ignored) in the package.
[DEBUG] Evaluating NuGet output for line:
Finished installing 'visualstudio2012professional' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure.
But unfortunately, Visual Studio isn't installed. The folders were created, but the IDE isn't there. (there is no DevEnv.exe)
Are there log files somewhere that are associated with the VS installer? Maybe an answer lies in there.
Hmm, I can't get the download that is used in that package to install, I am running a PS script so I am going to use this which seems to work:
$testFolder = Join-Path "${Env:ProgramFiles(x86)}" "Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
$alreadyInstalled = (Test-Path $testFolder)
if (!$alreadyInstalled)
{
Install-ChocolateyPackage 'VisualStudio2012Professional' 'exe' "/Full /Passive /NoRestart /Log $env:temp\vs.log" 'http://download.microsoft.com/download/D/E/8/DE8E42D8-7598-4F4E-93D4-BB011094E2F9/vs_professional.exe'
}

Resources