Deploy cloud function using cloud build

Viewed 66

This my package.json file

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "serve": "firebase emulators:start --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "16"
  },
  "main": "index.js",
  "dependencies": {
    "body-parser": "^1.20.0",
    "firebase-admin": "^10.0.2",
    "firebase-functions": "^3.18.0"
  },
  "devDependencies": {
    "firebase-functions-test": "^0.2.0"
  },
  "private": true
}

And this is my cloudbuild.yaml

steps:
#Install
- name: 'gcr.io/cloud-builders/npm'
  args: ['install']

enter image description here

I am trying to deploy cloud functions using cloud build but I am not getting the hosting URL for my code. Can anyone help me out?

1 Answers

The cloud build log details show that there is a npm WARN saveError ENOENT:no such file or directory, open ‘/workspace/package.json’ warning message.

The log also has a package-lock.json file to try eliminate this warnings and saveError delete package-lock.json file and then install packages,

rm package-lock.json && npm install

You can check a similar Stackoverflow question here.

Related