0

Im Kind of new to Android development.

I want to use Firebase Cloud to Recognize Text of non-Latin characters, to do so I'm following the official guide

my index.js(this is the basic one and i havent changed anything)

import * as functions from "firebase-functions";
import vision from "@google-cloud/vision";

const client = new vision.ImageAnnotatorClient();
export const annotateImage = functions.https.onCall(async (data, context) => {
  if (!context.auth) {
    throw new functions.https.HttpsError(
      "unauthenticated",
      "annotateImage must be called while authenticated."
    );
  }
  try {
    return await client.annotateImage(data);
  } catch (e) {
    throw new functions.https.HttpsError("internal", e.message, e.details);
  }
});

here is the .eslintrc.js

module.exports = {
  env: {
    browser: true,
    es2020: true,
    node: true,
  },
  extends: [
    "plugin:import/errors",
    "plugin:import/warnings",
  ],
  parser: "@typescript-eslint/parser",
  parserOptions: {
    project: "tsconfig.json",
    tsconfigRootDir: __dirname,
    sourceType: "module",

  },
  plugins: [
    "@typescript-eslint",
    "import",
  ],
  rules: {
    "max-len": ["error", {"code": 200}],
    "require-jsdoc": 0,
    "@typescript-eslint/adjacent-overload-signatures": "error",
    "@typescript-eslint/no-empty-function": "error",
    "@typescript-eslint/no-empty-interface": "warn",
    "@typescript-eslint/no-floating-promises": "error",
    "@typescript-eslint/no-namespace": "error",
    "@typescript-eslint/no-unnecessary-type-assertion": "error",
    "@typescript-eslint/prefer-for-of": "warn",
    "@typescript-eslint/triple-slash-reference": "error",
    "@typescript-eslint/unified-signatures": "warn",
    "comma-dangle": "warn",
    "constructor-super": "error",
    eqeqeq: ["warn", "always"],
    "import/no-deprecated": "warn",
    "import/no-extraneous-dependencies": "error",
    "import/no-unassigned-import": "warn",
    "no-cond-assign": "error",
    "no-duplicate-case": "error",
    "no-duplicate-imports": "error",
    "no-empty": [
      "error",
      {
        allowEmptyCatch: true,
      },
    ],
    "no-invalid-this": "error",
    "no-new-wrappers": "error",
    "no-param-reassign": "error",
    "no-redeclare": "error",
    "no-sequences": "error",
    "no-shadow": [
      "error",
      {
        hoist: "all",
      },
    ],
    "no-throw-literal": "error",
    "no-unsafe-finally": "error",
    "no-unused-labels": "error",
    "no-var": "warn",
    "no-void": "error",
    "prefer-const": "warn",
  },
  settings: {
    jsdoc: {
      tagNamePreference: {
        returns: "return",
      },
    },
  },
};

and this is the package.json file

   {
  "name": "functions",
  "scripts": {
    "lint": "eslint \"src/**/*\"",
    "build": "tsc",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log",
    "compile": "npm run build"
  },
  "engines": {
    "node": "16"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "^11.5.0",
    "firebase-functions": "^4.2.1",
    "@google-cloud/vision": "^2.1.2"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^3.9.1",
    "@typescript-eslint/parser": "^3.8.0",
    "eslint": "^7.6.0",
    "eslint-plugin-import": "^2.22.0",
    "typescript": "^3.8.0",
    "firebase-functions-test": "^3.0.0"
  },
  "private": true
}

when I try to deploy it using firebase deploy --only functions (like in the guide) and im getting the error(this is the complete debug log)

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Users\\genni\\DOWNLO~1\\firebase-tools-instant-win.exe',
1 verbose cli   'C:\\snapshot\\firepit\\node_modules\\npm\\bin\\npm-cli',
1 verbose cli   '--script-shell=C:\\Users\\genni\\.cache\\firebase\\runtime/shell.bat',
1 verbose cli   '--globalconfig=C:\\Users\\genni\\.cache\\firebase\\runtime\\npmrc',
1 verbose cli   '--userconfig=C:\\Users\\genni\\.cache\\firebase\\runtime\\npmrc',
1 verbose cli   '--scripts-prepend-node-path=auto',
1 verbose cli   '--prefix',
1 verbose cli   'C:\\Users\\genni\\AndroidStudioProjects\\functions-samples\\vision-annotate-images\\functions',
1 verbose cli   'run',
1 verbose cli   'build'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle functions@~prebuild: functions@
6 info lifecycle functions@~build: functions@
7 verbose lifecycle functions@~build: unsafe-perm in lifecycle true
8 verbose lifecycle functions@~build: PATH: C:\snapshot\firepit\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\genni\AndroidStudioProjects\functions-samples\vision-annotate-images\functions\node_modules\.bin;C:\Users\genni\DOWNLO~1;C:\Users\genni\CACHE~1\firebase\runtime;C:\Users\genni\.cache\firebase\tools\bin;C:\Users\genni\.cache\firebase\runtime;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\Program Files (x86)\VMware\VMware Player\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\Users\genni\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\genni\AppData\Local\Programs\Python\Python311\;C:\Users\genni\AppData\Local\Microsoft\WindowsApps;C:\Users\genni\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\genni\.dotnet\tools;C:\Users\genni\AppData\Local\gitkraken\bin;C:\Users\genni\AppData\Local\Microsoft\WindowsApps;C:\Program Files\JetBrains\PyCharm 2022.3.1\bin;C:\Users\genni\.dotnet\tools;C:\Users\genni\AppData\Roaming\npm
9 verbose lifecycle functions@~build: CWD: C:\Users\genni\AndroidStudioProjects\functions-samples\vision-annotate-images\functions
10 silly lifecycle functions@~build: Args: [ '-c', 'tsc' ]
11 silly lifecycle functions@~build: Returned: code: 2  signal: null
12 info lifecycle functions@~build: Failed to exec build script
13 verbose stack Error: functions@ build: `tsc`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (C:\snapshot\firepit\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (node:events:527:28)
13 verbose stack     at ChildProcess.<anonymous> (C:\snapshot\firepit\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (node:events:527:28)
13 verbose stack     at maybeClose (node:internal/child_process:1092:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
14 verbose pkgid functions@
15 verbose cwd C:\Users\genni\AndroidStudioProjects\functions-samples\vision-annotate-images
16 verbose Windows_NT 10.0.22621
17 verbose argv "C:\\Users\\genni\\DOWNLO~1\\firebase-tools-instant-win.exe" "C:\\snapshot\\firepit\\node_modules\\npm\\bin\\npm-cli" "--script-shell=C:\\Users\\genni\\.cache\\firebase\\runtime/shell.bat" "--globalconfig=C:\\Users\\genni\\.cache\\firebase\\runtime\\npmrc" "--userconfig=C:\\Users\\genni\\.cache\\firebase\\runtime\\npmrc" "--scripts-prepend-node-path=auto" "--prefix" "C:\\Users\\genni\\AndroidStudioProjects\\functions-samples\\vision-annotate-images\\functions" "run" "build"
18 verbose node v16.16.0
19 verbose npm  v6.14.18
20 error code ELIFECYCLE
21 error errno 2
22 error functions@ build: `tsc`
22 error Exit status 2
23 error Failed at the functions@ build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

i tried to do evreything from here and from here but still the same eror

11
  • This has nothing to do with eslint. This has to do with tsc -- TypeScript Compiler -- as evidenced by Error: functions@ build: tsc. Ensure tsc can complete successfully locally before attempting to deploy your function. Commented Apr 13, 2023 at 7:24
  • @anothermh how can i do that? Commented Apr 13, 2023 at 10:04
  • Run tsc locally Commented Apr 13, 2023 at 16:06
  • @anothermh can you help with im kinda new to this world Commented Apr 13, 2023 at 19:55
  • The command tsc is the TypeScript Compiler. It's what you run to transpile TypeScript into pure JavaScript. The error message you're seeing is saying that for some reason the command tsc failed. You should open a command prompt to your functions folder and run tsc or npm tsc and observe the output to look for errors. Commented Apr 13, 2023 at 19:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.