Add support for private npm modules
Steps to reproduce
- Include a private module in package.json. i.e. @org/name
- Throws an error when deploying:
Error: Cannot find module '@org/name'
Including .npmrc file at the root folder doesn't help. (https://docs.npmjs.com/private-modules/ci-server-config#checking-in-your-npmrc)
Also see here:
- http://stackoverflow.com/questions/42901076/how-to-use-private-npm-packages-with-cloud-functions
- https://issuetracker.google.com/issues/36665861
Hi guys. Is anyone working on this? Need to use this functionality ASAP.
Hello, are there any updates on this? This would be much needed indeed.
This is now supported 🎉
In order to use a private npm module, you have to provide credentials (auth token) for the npm registry in a .npmrc file located in the function's directory. You can simply copy the .npmrc file that was created in your home directory when you logged into npm using the npm login command.
Do not include the .npmrc file if you're not using private repositories, as it may increase the deployment time for your functions.
Source: https://cloud.google.com/functions/docs/writing/dependencies#using_private_modules