0

I just followed the firebase documentation (https://firebase.google.com/docs/functions/typescript) in order to migrate my cloud functions project to typescript and now, i Have the following error when I use : 'firebase deploy --only functions'

here is the stacktrace :

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

> functions@ lint (here is my project path)
> tslint -p tslint.json

Invalid option for project: tslint.json
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `tslint -p tslint.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/macbook/.npm/_logs/2020-12-08T17_25_16_433Z-debug.log

My tsconfig.json :

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017",
    "types": ["node"],
    "allowJs": true
  },
  "compileOnSave": true,
  "include": [
    "src"
  ]
}

My package.json :

{
  "name": "functions",
  "main": "./src/index.ts",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "./node_modules/.bin/tslint -p tslint.json",
    "build": "./node_modules/.bin/tsc",
    "serve": "npm run build && firebase serve --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"
  },
  "dependencies": {
    "cors": "^2.8.5",
    "firebase-admin": "^9.4.1",
    "firebase-functions": "^3.13.0",
    "googleapis": "^39.2.0",
    "request": "^2.88.2",
    "tslint": "^6.1.3",
    "typedi": "^0.8.0",
    "typescript": "^4.1.2"
  },
  "devDependencies": {
    "@types/node": "^14.14.10",
    "firebase-functions-test": "^0.1.7"
  },
  "private": true
}

3
  • I have tried almost everything that i could get on google but i'm realy getting low on idea now. I cannot move my project forward, if anybody got an idea it would be super appreciated ! Commented Dec 8, 2020 at 19:13
  • Could you please add the code of your cloud functions? This to be able to replicate to se what is going on. Commented Dec 9, 2020 at 0:54
  • was able to make it work as stated in my answer. Thank you for your concern ! Commented Dec 9, 2020 at 10:30

2 Answers 2

1

Maybe it's the same problem as described here

Try switching to,

"lint": "./node_modules/.bin/tslint -p tslint.json .", 

or replace the . with the path of the directory that you are linting

Sign up to request clarification or add additional context in comments.

1 Comment

unfortunately it did not change anything :(
0

At the end of the day, I reverted all the changes, cleaned the node_module and restarted the migration again.

I left my index as .js and not .ts for the moment and it worked. At the end, here is my conf in case it could help someone in the future :

package.json

{
  "name": "functions",
  "main": "src/index.js",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "build": "./node_modules/.bin/tslint --project tsconfig.json && ./node_modules/.bin/tsc",
    "serve": "firebase serve --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "12"
  },
  "dependencies": {
    "cors": "^2.8.5",
    "firebase-admin": "^9.4.1",
    "firebase-functions": "^3.13.0",
    "tslint": "^6.1.3",
    "typescript": "^4.1.2"
  },
  "devDependencies": {
    "firebase-functions-test": "^0.1.7"
  },
  "private": true
}

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "allowJs": true,
    "sourceMap": true,
    "strict": true,
    "target": "es2017"
  },
  "compileOnSave": true,
  "include": [
    "src"
  ],
  "allowJs": "true"
}

firebase.json

{
  "functions": {
    "predeploy": "npm --prefix \"$RESOURCE_DIR\" run build"
  }
}

Comments

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.