Skip to content

SSR / Compilation / Can't resolve 'google-auth-library' #3542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vroussel35 opened this issue Aug 3, 2020 · 5 comments
Closed

SSR / Compilation / Can't resolve 'google-auth-library' #3542

vroussel35 opened this issue Aug 3, 2020 · 5 comments

Comments

@vroussel35
Copy link

[REQUIRED] Describe your environment

  • Operating System version: Mac OS / SSR context
  • Browser version: N/A
  • Firebase SDK version: 7.15.2 and above
  • Firebase Product: all (auth, database, storage, etc)

[REQUIRED] Describe the problem

Error when trying to execute npm run dev:ssr

ERROR in ./node_modules/@grpc/grpc-js/build/src/channel-credentials.js
Module not found: Error: Can't resolve 'google-auth-library' in '[local-project-directory]/node_modules/@grpc/grpc-js/build/src'
this.debug is not a function

This problem has started from firebase version 7.15.2 where the grpc-js dependancy version has been modified to ^1.0.0.

Steps to reproduce:

  1. Download this project https://github.com/vroussel35/error-ssr-compile
  2. Execute npm install
  3. Execute npm run dev:ssr
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@siva636
Copy link

siva636 commented Aug 5, 2020

I also face the same issue. I use:
"firebase": "^7.13.1",
"@angular/fire": "^6.0.2",

@vroussel35
Copy link
Author

@siva636 In the meantime - waiting for a fix - if you use "firebase": "7.15.1" instead of "firebase": "^7.13.1", it should be OK.

@wu-hui
Copy link
Contributor

wu-hui commented Aug 13, 2020

Looks like newer version of the SDK no longer has this problem? At least 7.17 looks fine to me.

@wu-hui wu-hui closed this as completed Aug 14, 2020
@vroussel35
Copy link
Author

vroussel35 commented Aug 14, 2020

Hi @wu-hui - the newer version of the SDK still has this problem.

To fix this issue (or better to say, to put in place a workaround), from version 7.15.2 of the firebase package, you have to modify the angular.json file and add the @firebase package to the externalDependencies config of the "server" target as explained by @Feiyang1 in #3541 (comment).

The result looks like this:

"server": {
 "builder": "@angular-devkit/build-angular:server",
 "options": {
  "outputPath": "dist/server",
  "main": "server.ts",
  "tsConfig": "tsconfig.server.json",
  "externalDependencies": [
   "@firebase/analytics",
   "@firebase/analytics-types",
   "@firebase/app",
   "@firebase/app-types",
   "@firebase/auth",
   "@firebase/auth-interop-types",
   "@firebase/auth-types",
   "@firebase/component",
   "@firebase/database",
   "@firebase/database-types",
   "@firebase/firestore",
   "@firebase/firestore-types",
   "@firebase/functions",
   "@firebase/functions-types",
   "@firebase/installations",
   "@firebase/installations-types",
   "@firebase/logger",
   "@firebase/messaging",
   "@firebase/messaging-types",
   "@firebase/performance",
   "@firebase/performance-types",
   "@firebase/polyfill",
   "@firebase/remote-config",
   "@firebase/remote-config-types",
   "@firebase/storage",
   "@firebase/storage-types",
   "@firebase/util",
   "@firebase/webchannel-wrapper",
  ]
 },
 ...

The root cause of this issue is most probably due to "some agressive tree-shaking somewhere in the ngcc build tooling" as mentioned by @jamesdaniels in this #3541 (comment)

PS : from an IT process point of view, I would have not closed this issue as its root cause has not been clearly identified and a proper fix is not in place... ;)

@firebase firebase locked and limited conversation to collaborators Sep 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants