I have installed husky
in my npm project as a prepare
script like below
{
"name": "functions",
"scripts": {
"build": "tsc",
"start": "npm run serve",
"deploy": "firebase deploy --only functions",
"prepare": "husky install functions/.husky"
}
"dependencies": {
"firebase-admin": "^11.4.1",
"firebase-functions": "^4.1.1",
},
"devDependencies": {
"husky": "^8.0.2",
"typescript": "^4.9.4"
}
}
husky
is declared as devDependencies
as this npm module is only required while local development and has no need in runtime app.
So when I run npm run deploy
, I get the below error
i functions: updating Node.js 16 function funName(us-central1)...
Build failed:
> prepare
> husky install functions/.husky
sh: 1: husky: not found
npm ERR! code 127
npm ERR! path /workspace
npm ERR! command failed
npm ERR! command sh -c -- husky install functions/.husky
This error clearly states that husky
is not installed.
One possible solution is to create a prepare.js
script which checks if the script is running while in local development or in the firebase server(to prepare the project) and then conditionally run the husky
npm module command
dependencies
block.. Let me update the question. Now it seems like I am missing some setup of husky with firebase functions – Nitrite