Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Functions Firebase CLI predeploy error (typescript)

I´m trying Cloud Functions with typescript.
After successfully installed, added a trigger and tested deploy.

index.ts

import * as functions from 'firebase-functions';

export const createAccount = functions.auth.user().onCreate(event => {
    const user = event.data;
    console.log('user displayname', user.displayName);
    return;
});

command

firebase deploy --only functions

=== Deploying to 'project'...

i  deploying functions
i  functions: running predeploy script.

> functions@ build D:\vmbox\project\firebase\functions
> tslint -p tslint.json && ./node_modules/.bin/tsc

ERROR

'.' is not recognized as an internal or external command,
operable program or batch file.

Environment
firebase cli v3.16.0
node v6.11.2
npm v4.2.0
OS: Windows 10
terminal: powershell

///

Rollback to Javascript

I re-initiated functions with Javascript option, and also got errors when deploying.
I guess it may be related to a setup made by the cli for typescript.
Had to delete the "functions" option added to "firebase.json".

option deleted in firebase.json:

  "functions": {
    "predeploy": "npm --prefix functions run build"
  }
like image 362
guillefd Avatar asked Dec 11 '17 15:12

guillefd


People also ask

Does firebase work with TypeScript?

Using an existing TypeScript project With this configuration, a firebase deploy --only functions command builds your TypeScript code and deploys it as functions.

How many requests can handle a single cloud function?

By default each Cloud Run container instance can receive up to 80 requests at the same time; you can increase this to a maximum of 1000.

What language would you like to use to write cloud functions?

Cloud Functions current supports the Node. js 8 JavaScript Runtime, and the Node. js 10 Engine is in beta. You can choose a Node version it from your package.


2 Answers

Just replace inside the package.json this

"build": "./node_modules/.bin/tslint.cmd -p tslint.json && ./node_modules/.bin/tsc.cmd"

on this

"build": ".\\node_modules\\.bin\\tslint.cmd -p tslint.json && .\\node_modules\\.bin\\tsc.cmd"

and it will work on windows.

like image 100
Andrew Veresov Avatar answered Oct 28 '22 13:10

Andrew Veresov


add this line to tsconfig within the functions folder:

"typeRoots": [
  "node_modules/@types"
],

This is part of "compilerOptions" block worked for me

like image 24
Kisinga Avatar answered Oct 28 '22 12:10

Kisinga