title: use Google Cloud Functions with a registry other than registry.npmjs.org
body: <p>I'm currently trying to deploy a node.js cloud function using a (private) package from the GitHub package registry (npm.pkg.github.com).</p>
  
  <p>According to the official docs <a href="https://cloud.google.com/functions/docs/writing/specifying-dependencies-nodejs#using_private_modules" rel="noreferrer">here</a>, using private modules is supported by adding a .npmrc file with an access token, however there is no mention of using custom registries.</p>
  
  <p>The .npmrc which I upload to Cloud Functions alongside the package.json and the rest of the code looks like this:</p>
  
  <pre><code>registry=https://npm.pkg.github.com/&lt;myorg&gt;
  //npm.pkg.github.com/:_authToken=&lt;mytoken&gt;
  </code></pre>
  
  <p>However, the deployment fails due to:</p>
  
  <pre><code>Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`npm_install` had stderr output:
  npm ERR! code E404
  npm ERR! 404 Not Found - GET https://registry.npmjs.org/&lt;mypackage&gt; - Not found
  npm ERR! 404 
  npm ERR! 404 '&lt;mypackage&gt;' is not in the npm registry.
  npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
  </code></pre>
  
  <p>So as you can see, the registry definition from the .npmrc seems to be ignored, as it tries to pull the package from npmjs.org, where it does indeed not exist.</p>
  
  <p>Do Google Cloud Functions not support custom registries?</p>
  
  <hr>
  
  <p>Edit: added verbose log output</p>
  
  <pre><code>Deploying function (may take a while - up to 2 minutes)...failed.
  DEBUG: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`npm_install` had stderr output:\nnpm ERR! code E404\nnpm ERR! 404 Not Found - GET https://registry.npmjs.org/&lt;redacted&gt; - Not found\nnpm ERR! 404 \nnpm ERR! 404  '&lt;redacted&gt;' is not in the npm registry.\nnpm ERR! 404 You should bug the author to publish it (or use the name yourself!)\nnpm ERR! 404 It was specified as a dependency of 'functions'\nnpm ERR! 404 \nnpm ERR! 404 Note that you can also install from a\nnpm ERR! 404 tarball, folder, http url, or git url.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /builder/home/.npm/_logs/2020-02-12T14_14_22_565Z-debug.log\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! @ preinstall: `./install-function-dependencies`\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the @ preinstall script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /builder/home/.npm/_logs/2020-02-12T14_14_22_586Z-debug.log\n\nerror: `npm_install` returned code: 1", "errorType": "InternalError", "errorId": "BDE5340F"}}
  Traceback (most recent call last):
    File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 981, in Execute
      resources = calliope_command.Run(cli=self, args=args)
    File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 807, in Run
      resources = command_instance.Run(args)
    File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/surface/functions/deploy.py", line 307, in Run
      return _Run(args, track=self.ReleaseTrack())
    File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/surface/functions/deploy.py", line 263, in _Run
      op, do_every_poll=TryToSetInvokerPermission)
    File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 306, in CatchHTTPErrorRaiseHTTPExceptionFn
      return func(*args, **kwargs)
    File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 353, in WaitForFunctionUpdateOperation
      do_every_poll=do_every_poll)
    File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 137, in Wait
      _WaitForOperation(client, request, notice, do_every_poll)
    File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 111, in _WaitForOperation
      sleep_ms=SLEEP_MS)
    File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 219, in RetryOnResult
      result = func(*args, **kwargs)
    File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 70, in _GetOperationStatus
      raise exceptions.FunctionsError(OperationErrorToString(op.error))
  FunctionsError: OperationError: code=3, message=Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`npm_install` had stderr output:\nnpm ERR! code E404\nnpm ERR! 404 Not Found - GET https://registry.npmjs.org/&lt;redacted&gt; - Not found\nnpm ERR! 404 \nnpm ERR! 404  '&lt;redacted&gt;' is not in the npm registry.\nnpm ERR! 404 You should bug the author to publish it (or use the name yourself!)\nnpm ERR! 404 It was specified as a dependency of 'functions'\nnpm ERR! 404 \nnpm ERR! 404 Note that you can also install from a\nnpm ERR! 404 tarball, folder, http url, or git url.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /builder/home/.npm/_logs/2020-02-12T14_14_22_565Z-debug.log\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! @ preinstall: `./install-function-dependencies`\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the @ preinstall script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /builder/home/.npm/_logs/2020-02-12T14_14_22_586Z-debug.log\n\nerror: `npm_install` returned code: 1", "errorType": "InternalError", "errorId": "BDE5340F"}}
  </code></pre>