5

I am trying to learn how to deploy the typescript onto my FCF but it seems not doing the deployment that it should do like in the documentation and the official video of firecasts. When I tried to deploy my default code of helloworld instead of typescript, it is deploying node.js file which is I don't understand why? Below are some json files and ts files, Please take a look at those generated files.

tsconfig.json
{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017"
  },
  "compileOnSave": true,
  "include": [
    "src"
  ]
}
package.json
{
  "name": "functions",
  "scripts": {
    "lint": "./node_modules/.bin/tslint -p tslint.json",
    "build": "./node_modules/.bin/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"
  },
  "engines": {
    "node": "8"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "^8.10.0",
    "firebase-functions": "^3.6.0"
  },
  "devDependencies": {
    "tslint": "^5.12.0",
    "typescript": "^3.2.2",
    "firebase-functions-test": "^0.2.0"
  },
  "private": true
}
index.ts

import * as functions from 'firebase-functions';

// Start writing Firebase Functions
// https://firebase.google.com/docs/functions/typescript

export const helloWorld = functions.https.onRequest((request, response) => {
 response.send("Hello from Firebase!");
});

Lastly here is the result when deploying the code:

=== Deploying to 'gym-system-63a51'...

i  deploying functions
Running command: npm --prefix functions run build

> functions@ build C:\Users\FX504GE-EN179T\Desktop\Clustore_App\MapboxTest\TypeScript\functions
> tslint -p tslint.json && tsc

Running command: npm --prefix "$RESOURCE_DIR" run lint

> functions@ lint C:\Users\FX504GE-EN179T\Desktop\Clustore_App\MapboxTest\TypeScript\functions
> tslint -p tslint.json

Running command: npm --prefix "$RESOURCE_DIR" run build

> functions@ build C:\Users\FX504GE-EN179T\Desktop\Clustore_App\MapboxTest\TypeScript\functions
> tslint -p tslint.json && tsc

+  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...

!  functions: The Node.js 8 runtime is deprecated and will be decommissioned on 2020-12-05. For more information, see: https://firebase.google.com/support/faq#functions-runtime

+  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (29.86 KB) for uploading
+  functions: functions folder uploaded successfully
i  functions: updating Node.js 8 function helloWorld(us-central1)...
+  functions[helloWorld(us-central1)]: Successful update operation.

+  Deploy complete!

enter image description here

I have a hunch that the engines in package.json is the reason? But I don't know what number I should update it with. Thank you!

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Mr. Baks
  • 297
  • 2
  • 6
  • 20
  • Please edit the question to show the code as well as any error messages you see. Just stating that it doesn't work isn't helpful information. There should be enough information so that anyone can reproduce the same thing. – Doug Stevenson Jul 23 '20 at 04:07
  • Okay please wait. I will update it – Mr. Baks Jul 23 '20 at 04:08
  • @DougStevenson I updated the question, please take a look at it. Thanks! – Mr. Baks Jul 23 '20 at 04:12
  • Did you read the warning message in the deployment? "The Node.js 8 runtime is deprecated and will be decommissioned on 2020-12-05. For more information, see: https://firebase.google.com/support/faq#functions-runtime" – Doug Stevenson Jul 23 '20 at 04:24
  • Is it okay that It deploys Node.js 8? I want remove the warning of Node.js 8 has been deprecated, so I thought that maybe changing to typescript might remove it. – Mr. Baks Jul 23 '20 at 04:27
  • 1
    The deployment worked just fine. You can see that in the output. – Doug Stevenson Jul 23 '20 at 04:29

1 Answers1

4

The node 8 runtime is deprecated and will be discontinued. Follow the link in the warning message for more information. You will need to migrate to node 10 eventually. Minimally, you will need to make sure this is set in your package.json:

  "engines": {
    "node": "10"
  },
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441