0

When deploying a Node.js function using the firebase CLI are the node_packages uploaded or are they installed in the cloud based on the package.json (or lock file)?

I am trying to set up a CI flow in GitHub actions using the CLI and the functions doesn't seem to find the dependencies. Do I perhaps need to use the predeploy option in firebase.json to install the dependencies using npm ci?

Thanks!

Sathi Aiswarya
  • 2,068
  • 2
  • 11
Christian R
  • 1,545
  • 3
  • 13
  • 17
  • If a package-lock.json or yarn.lock file is found within your project, that lock file will be respected when dependencies are installed using npm ci or yarn install.please refer this [document1](https://cloud.google.com/functions/docs/writing/specifying-dependencies-nodejs) & [document2](https://firebase.google.com/docs/functions/handle-dependencies) – Sathi Aiswarya Oct 12 '22 at 07:29
  • Thanks for your response, read that also in the docs but for me its still unclear wether I need to explicitly call npm ci in the predeploy options or if this is done automatically in the cloud? – Christian R Oct 12 '22 at 18:14
  • I think it is better to run `npm ci` .This way you can ensure that your pipeline uses exactly the same dependencies you last used locally and can confirm that they worked for you.check this stackoverflow [link1](https://stackoverflow.com/questions/69459919/what-exactly-does-npm-ci-command-does-why-is-it-used-in-all-ci-pipelines-inste) & [link2](https://stackoverflow.com/questions/52499617/what-is-the-difference-between-npm-install-and-npm-ci) – Sathi Aiswarya Oct 14 '22 at 09:09
  • Thanks for your input, yes npm ci is the better option – Christian R Oct 14 '22 at 11:51
  • I have provided an answer below,so that others could spot the workaround easier.please check – Sathi Aiswarya Oct 18 '22 at 13:17

1 Answers1

0

It is better to use npm ci .This way you can ensure that your pipeline uses exactly the same dependencies you last used locally and can confirm that they worked for you

npm ci performs a clean install of all the dependencies of your app and it is great for ci/cd pipelines and docker builds!

You can also check this stackoverflow link1 & link2 for more information

Sathi Aiswarya
  • 2,068
  • 2
  • 11