firebase-tools: Error: functions/index.js does not exist, can't deploy Firebase Functions
Version info
3.17.3
Steps to reproduce
Setup a new typescript project
Run npm run build
Expected behavior
It deploys and uses the file from lib/index.js (which it isn’t) declared in package.json under main
Actual behavior
npm run deploy --debug
> @ deploy XXX/functions
> firebase deploy --only functions
=== Deploying to 'XXX-XXXX'...
i deploying functions
Running command: npm --prefix $RESOURCE_DIR run build
> @ build /XXX/functions
> tsc
✔ functions: Finished running predeploy script.
Error: functions/index.js does not exist, can't deploy Firebase Functions
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ deploy: `firebase deploy --only functions`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ deploy 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/DFischer/.npm/_logs/2018-01-24T15_28_36_051Z-debug.log```
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 30 (8 by maintainers)
@daniil-konovalenko You’re missing the “main” field in your package.json. Please add
"main": "lib/index.js"to your package.json.solved by setting “main” in package.json to:
"main": "lib/functions/src/index.js"JUST SOLVED THIS AND FOUND WHAT I THINK IS A BUG The g cloud function does not support the “lib” name for the folder that contains your compiled js
MY SOLUTION: My env: [Nodejs16 - I dont think it matters the version] [Typescript ^4.0.0 - I dont think it matters the version, but it has to be on typescript ]
Edit package.json file … edit
"main": "lib/index.js",for"main": "blablabla/index.js",,Then, to be consistent, go to your tsconfig.json file and edit
"outDir": "blablabla",,Also if you are using a github action, make sure you add
source_dir: 'functions'in the with statement.