hmm. that is pretty weird. Lets do some sanity checks.
Have you tried to “clear cache and redeploy”?
Is your package.json getting committed to your repo? There have been times when people have had their .gitignore set up in such a way that it never got updated.
so the question I have (and I am not a firebase expert) is to whether we are actually not finding/downloading the package or whether compilation of the project is failing because something about how the module is getting imported into the code isn’t right. Sometimes compilation fails for things like this:
I’m going to ask an engineer who knows a bit more about this than i do to take a look, also.
Good question. At the moment I’m not sure there’s anything special about the firebase-admin admin package, and I successfully use it in Netlify functions in my other projects. That’s why I’m confused why it’s not working in this case.
It would be great to check with an engineer for sure. Looking forward to your updates. Thanks!
I presume that you have a package.json in your function folder. Note that the buildbot won’t automatically npm i or yarn install. You’ll need to do that as part of your build command. Could you try something like cp function/db && npm i && cd ../.. && npm run build and see if that helps? (You’d probably want to extrapolate that command to fit your needs)
Correct @Dennis. I have a package.json in my function folder. It works when testing locally.
I’m confused re: your second question: in my experience, after I create a function using netlify functions:create foo and then npm i package-name to install a package, I can require that package within the functions index.js file, and then when building the project as a whole, that function’s packages are automatically built by Netlify. This workflow has been working for me in the recent months I’ve been using Netlify.
Could you please confirm that builtbot does not actually npm i the packages listed as dependencies in a function’s package.json file before running the function?
If you are using the cli to deploy, then you aren’t using our buildbot at all. This bundling process is done at deploy time and not at runtime, so I think perhaps I wasn’t clear. When I mentioned that function dependencies aren’t automatically installed, I assumed you deployed via a linked repo on your site and not via the cli, which use different code to bundle up your function.
That said, can you point to your site directly so I can take a look to see how your site is being deployed rather than guessing?