The problem with Node.js environments that they store dependencies locally in your project's directory.
Basically, before deploying your function, you will need to first delete the node_modules directory and then deploying the function to the cloud.