firebase-functions: Cannot deploy private packages with Node 10

Version info node: 10.10.0 / 8.15.0 firebase-functions: 3.1.0 firebase-tools: 7.12.0

[REQUIRED] Test case N/A

[REQUIRED] Steps to reproduce Updating node 8.* to 10.* causes deployment errors. Firebase deploy seem to fail when:

i  functions: updating Node.js 10 (Beta) function api(us-central1)...
i  functions: updating Node.js 10 (Beta) function projector(us-central1)...

Unfortunately, an unauthorized error is given when accessing a private registry for dependencies. It seems that the .npmrc is ignored as it holds the _auth.

[REQUIRED] Expected behavior Trying to deploy should not fail. For now, I’m still using node 8.

[REQUIRED] Actual behavior

i  functions: updating Node.js 10 (Beta) function projector(us-central1)...
⚠  functions[projector(us-central1)]: Deployment error.
Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`npm_install` had stderr output:\nwarning ../package.json: No license field\nerror An unexpected error occurred: \"https://artifactory.persgroep.cloud/artifactory/api/npm/npm/vary/-/vary-1.1.2.tgz: Request failed \\\"401 Unauthorized\\\"\".\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-01-15T11_47_09_141Z-debug.log\n\nerror: `npm_install` returned code: 1", "errorType": "InternalError", "errorId": "67EE7395"}}
⚠  functions[api(us-central1)]: Deployment error.
Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`npm_install` had stderr output:\nwarning ../package.json: No license field\nerror An unexpected error occurred: \"https://artifactory.persgroep.cloud/artifactory/api/npm/npm/accepts/-/accepts-1.3.7.tgz: Request failed \\\"401 Unauthorized\\\"\".\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-01-15T11_47_09_583Z-debug.log\n\nerror: `npm_install` returned code: 1", "errorType": "InternalError", "errorId": "1600C76E"}}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 15
  • Comments: 39 (3 by maintainers)

Most upvoted comments

We’ve got exactly the same issue, works fine on node 8, but node 10 deployment doesn’t seem to be using the .npmrc file

It seems the problem is still there as of today. I have a private package used by some of my functions. Functions are all using node 10. I placed a .npmrc in functions directory. It contains something like:

//npmregistry.somewebsite.io/:_authToken=THE_TOKEN_HERE

Installing, building locally works fine. But at deploy time:

Deployment error.
Build failed: error An unexpected error occurred:
"https://npmregistry.somewebsite.io/mypackage/-/mypackage-1.2.0.tgz: 
Request failed \"401 Unauthorized\"".; Error ID: cbdcecb0

Isn’t the .npmrc of functions directory supposed to be transmitted and used while deploying?

Any update on when this might be fixed??

I’m not sure if this is exactly the same issue, but I’m having very similar problems migrating from node 8 to node 10 - tried multiple times in the last week (and over the past few months) and having the same issue: https://stackoverflow.com/questions/61962810/firebase-cloud-functions-cannot-deploy-to-node-10-upgrading-from-node-8

NB: I do not have any private packages - everything in my package.json is installed from NPM

I can’t fathom how literally nothing has been done yet. I am experiencing this issue with Node 12 & 14.

@andieromero

We apologize for the delay - the Cloud Functions team is working on Node 10 support but unfortunately it is not available yet. We recommend staying on Node 8

Thank you for working on it. Since this bug is a blocker for us to launch a new project, I’m happy to help you.

I have couple of questions:

  • Is this a bug of only firebase-CLI/firebase functions/cloud functions itself?
  • Is there any active branch/thread/mailing list which is working on this issue?

Not answering for Firebase but I can say that my private packages are being installed nicely on node 14.

Do you have any logs of your deployment ?

Here’s my logs. I keep getting 404 even though on the local version npm finds and downloads that package no problem.

{
  "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
  "status": {
    "code": 3,
    "message": "Build failed: npm ERR! code E404\nnpm ERR! 404 Not Found - GET https://registry.npmjs.org/@kobxyz%!f(MISSING)lib-js - Not found\nnpm ERR! 404 \nnpm ERR! 404  '@kobxyz/lib-js@1.0.16' 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 \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!     /www-data-home/.npm/_logs/2021-08-20T04_15_59_879Z-debug.log; Error ID: beaf8772"
  },
  "authenticationInfo": {
    "principalEmail": "koby@kob.xyz"
  },
  "serviceName": "cloudfunctions.googleapis.com",
  "methodName": "google.cloud.functions.v1.CloudFunctionsService.UpdateFunction",
  "resourceName": "projects/kob-api/locations/us-central1/functions/google-helloWorld"
}

have you made any special configurations in your functions/.npmrc or other files? I tried so many variations but nothing worked for me. currently my file looks like this:

//npm.pkg.github.com/:_authToken=<token>
@KobXYZ:registry=https://npm.pkg.github.com

@kob490 We haven’t taken additional issue since my last comment. We haven’t add any luck having the issue reproduced on our side 😦.

@Ranguna Thanks for giving us another signal. It looks like the issue could be Google project specific or Github NPM package specific?

I am having the same issue when trying to deploy with private packages. I have packages deployed to Github Packages, and it is working fine in local emulator.

⚠  functions[transactions-onWriteTransaction(us-central1)]: Deployment error.
Build failed: yarn install v1.22.4
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.                                                                                                                                                                                                                                                                      
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
error An unexpected error occurred: "https://npm.pkg.github.com/download/@my-org/models/1.0.3-alpha.0/3fxxxx: Request failed \"401 Unauthorized\"".
info If you think this is a bug, please open a bug report with the information provided in "/workspace/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.; Error ID: 68f79024

I am using nodejs 10 because Node.js 8 is deprecated according to firebase documentation. From what I can tell, it is reading the proper registry from my .npmrc file, because the path seems to be correct https://npm.pkg.github.com/download/@my-org/models..., but it’s not reading my auth token which is also specified in the same file.

Here is my .npmrc

//npm.pkg.github.com/:_authToken=token
@my-org:registry=https://npm.pkg.github.com/my-org

This is kind of a huge block for me, so it would be appreciated if this issue got a bit more attention.

@andieromero , unfortunately staying on node8 will break dependency of my app. Thus only way to run firebase function with node is to fix the bug, I think.