'Cannot deploy firebase cloud functions, because functions/lib/index.js does not exist
I think there is a bug in firebase cloud functions setup.
I did:
npm install -g firebase-tools
firebase init functions
I have configured it for typescript, everything installed, yet I cannot deploy the functions because I am getting this error message:
Error: There was an error reading functions/package.json:
functions/lib/index.js does not exist, can't deploy Cloud Functions
I know that it does not exist - there is no lib folder at all, but what can I do to run the functions?
Why I can't run functions, if I done everything that needed to be done?
Solution 1:[1]
I understand you might be following the instructions from the Getting started guide or the Use Typescript for Cloud Functions one, during this section the wizard helps you choose Typescript as your language to write Functions. Please be sure the language and its dependencies are correctly installed. And in this last guide for the Using an existing Typescript project, it asks you to edit the package.json to add a bash script to build your typescript project:
{
"name": "functions",
"scripts": {
"build": "npm run lint && tsc"
}
...
and the firebase.json to add a predeploy hook to run the build script:
{
"functions": {
"predeploy": "npm --prefix functions run build",
}
}
but in this case, you need to check if this configuration was made during the installation.
You can check this answer where the user used sudo npm install typescript to install them, and as Doug mentions try to install it only in your project, not globally; and it must be defined in your package.json as well.
Another example that fixed a similar issue where:
- The user removed everything related to Firebase Functions
- Entered in the project directory using
cd functions(in this case replace the ‘functions’ name for your project) - Ran
npm install - Running again
firebase init
Let me know if you were able to solve this problem to further assist you, trying to add more information as steps and documentation followed and the logs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

