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!
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!
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"
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With