Skip to content

Function deployment fails with npm workspaces/nx - Error: spawn ./node_modules/.bin/firebase-functions ENOENT #4952

@rahuld600

Description

@rahuld600

[REQUIRED] Environment info

firebase-tools: 11.8.0 (latest release)

Platform: : macOS

[REQUIRED] Test case

If I make a function on the index.js file, and then I try to deploy using:
firebase deploy --only functions:nameOfYourFunction
I get an Unexpected Error at the end.

[REQUIRED] Steps to reproduce

Using npm or whatever package manager you prefer, run these on your terminal,

npm install -g firebase-tools
firebase login
firebase init functions

Now under the functions folder, make sure you have installed node modules using npm install,
and finally you create a basic function you like on index.js after you are done importing stuffs, for example:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

exports.yourFunctionName = functions.https.onRequest(async(req,res)=>{
functions.logger.log(res.body); //just for an example.
})

Now when you try to do:

firebase deploy --only functions:yourFunctionName

You'll see this error message in the end:

[debug] [2022-09-05T11:21:08.962Z] Building nodejs source
[debug] [2022-09-05T11:21:08.963Z] Could not find functions.yaml. Must use http discovery
[debug] [2022-09-05T11:21:08.972Z] Error: spawn ./node_modules/.bin/firebase-functions ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
[error]
[error] Error: An unexpected error has occurred.
[debug] [2022-09-05T11:21:09.063Z] Serving at port 9005

[REQUIRED] Expected behavior

Expected behaviour is that the function gets deployed successfully without any error.

[REQUIRED] Actual behavior

Actual behaviour is that function normally get's deployed successfully and just after this update, this issue came into play.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions