jsontypescriptfirebasenpmgoogle-cloud-functions

functions/lib/functions/src/index.ts does not exist, can't deploy Cloud Functions


When I try deploying my Firebase cloud functions I get the following error.

Desired behavior: Deploy functions successfully.

Error:

Error: There was an error reading functions/package.json:

functions/lib/index.js does not exist, can't deploy Cloud Functions

Full log:

name@name-MacBook-Pro functions % firebase deploy

=== Deploying to 'newtiktok-21570'...

i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run lint

functions@ lint /Users/name/Desktop/Yoveo/functions eslint "src/**/*"

/Users/name/Desktop/Yoveo/functions/src/index.ts
186:67 warning 'timestamp' is defined but never used
@typescript-eslint/no-unused-vars 377:86 warning 'mediaNum' is defined but never used @typescript-eslint/no-unused-vars 377:104 warning 'commentText' is defined but never used @typescript-eslint/no-unused-vars 377:125 warning 'commentID' is defined but never used @typescript-eslint/no-unused-vars 419:119 warning 'commentID' is defined but never used
@typescript-eslint/no-unused-vars 463:121 warning 'commentID' is defined but never used @typescript-eslint/no-unused-vars 520:75
warning 'mediaNum' is defined but never used
@typescript-eslint/no-unused-vars 732:25 warning 'slap' is defined but never used @typescript-eslint/no-unused-vars

āœ– 8 problems (0 errors, 8 warnings)

Running command: npm --prefix "$RESOURCE_DIR" run build āœ” functions: Finished running predeploy script.

Error: There was an error reading functions/package.json:

My p.json:

 {
  "name": "functions",
  "scripts": {
    "lint": "eslint \"src/**/*\"",
    "build": "",
    "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": "12"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "^9.2.0",
    "firebase-functions": "^3.11.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^4.8.1",
    "@typescript-eslint/parser": "^4.8.1",
    "eslint": "^7.14.0",
    "eslint-plugin-import": "^2.22.0",
    "firebase-functions-test": "^0.2.0",
    "typescript": "^3.8.0"
  },
  "private": true
}

Solution

  • Solved:

    I was able to solve the problem by removing everything associated with Firebase functions. And running: firebase init again. After I cd functions run npm install. Then I was able to deploy successfully after fixing an error with:

        3:26  error    'express' should be listed in the project's dependencies. Run 'npm i -S express' to add it  import/no-extraneous-dependencies