1
votes

so I am trying to use cloud functions, and I want to test to run my function locally. so I try to use Function Framework.

but it seems I failed to install the package, it is said, found 11 high severity vulnerabilities like this:

enter image description here

added 2 packages from 2 contributors and audited 1039 packages in 5.687s found 11 high severity vulnerabilities

enter image description here

so when I try to run my code locally. I failed with this error:

Error: Cannot find module '/Users/muchammadagunglaksana/Documents/kumpul_muslim/cloud_functions_serverless_backend/functions/functions-framework' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3) Muchammads-MacBook-Air:functions muchammadagunglaksana$ node functions-framework --target=helloWorld internal/modules/cjs/loader.js:638 throw err; ^

Error: Cannot find module '/Users/muchammadagunglaksana/Documents/kumpul_muslim/cloud_functions_serverless_backend/functions/functions-framework' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

even though it seems it has been installed in package.json enter image description here

what went wrong in here ?

1
most of the time, you can do nothing until the package fixed by their devs. however, you can try npm audit fix --force and see if there is new version with the issue fixed already. i also noticed your firebase-admin is not of latest.Bagus Tesa
Please don't show screenshots of text. It's easier to read and search if you simply copy the text into the question itself.Doug Stevenson
@DougStevenson thank you for the remainder. I have added the text of the error as wellAlexa289
There's still plenty of text here that could be moved out of images into the question (like all of them, as it doesn't matter if you're using VS code or not).Doug Stevenson

1 Answers

3
votes

It does not fail to install the package, it apparently contains some security vulnerabilities, but it still installs normally.

You're getting an error since you're using the node command wrong. It cannot find the module, since when you're running node functions-framework --target=helloWorld, it is looking for a file called functions-framework in your current directory. You should rather use npm to run the binary. Add a run script in package.json. Something like this

"scripts": {
  "start": "functions-framework --target=helloWorld"
}

Then use npm run start.