question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module not found: Can't resolve 'child_process' in google-auth-library

See original GitHub issue

Related issues

[REQUIRED] Version info

node: v.8.16.2

firebase-functions: 3.3.0

firebase-tools: 7.10.0

firebase-admin: 8.9.0

[REQUIRED] Test case

Here’s a simple example of this code, It’s just as it is! The only problem is to get the functions config(). https://codesandbox.io/s/exciting-leftpad-l27tt

[REQUIRED] Steps to reproduce

Try to get the Firebase hosting env variables via code, and get the child_process error for /node_modules/google-auth-library/build/src/auth.

'm trying to call it on the client via CI/CD pipeline, calling directly through the node exec or using an import from firebase-admin and both haven’t worked.

[REQUIRED] Expected behavior

Getting the envs from .runtimeconfig.json in case is development, otherwise get it from functions.config() method.

[REQUIRED] Actual behavior

Could not find files for /index in .next/build-manifest.json

ModuleNotFoundError: Module not found: Error: Can't resolve 'child_process' in '/home/myproject/node_modules/google-auth-library/build/src/auth'
    at factory.create (/home/myproject/node_modules/webpack/lib/Compilation.js:925:10)
    at factory (/home/myproject/node_modules/webpack/lib/NormalModuleFactory.js:401:22)
    at resolver (/home/myproject/node_modules/webpack/lib/NormalModuleFactory.js:130:21)
    at asyncLib.parallel (/home/myproject/node_modules/webpack/lib/NormalModuleFactory.js:224:22)
    at /home/myproject/node_modules/neo-async/async.js:2830:7
    at /home/myproject/node_modules/neo-async/async.js:6877:13
    at normalResolver.resolve (/home/myproject/node_modules/webpack/lib/NormalModuleFactory.js:214:25)
    at doResolve (/home/myproject/node_modules/enhanced-resolve/lib/Resolver.js:213:14)
    at hook.callAsync (/home/myproject/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
    at _fn0 (eval at create (/home/myproject/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at resolver.doResolve (/home/myproject/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7)
    at hook.callAsync (/home/myproject/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
    at _fn0 (eval at create (/home/myproject/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at hook.callAsync (/home/myproject/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
    at _fn0 (eval at create (/home/myproject/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
    at resolver.doResolve (/home/myproject/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43)

Were you able to successfully deploy your functions?

I’m not able to deploy it if I want to get Firebase envs from functions config() method.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:19

github_iconTop GitHub Comments

39reactions
cmlbrnccommented, Jun 6, 2020

I am using react next.js and getting the same error. If I don’t use firestore, I have to transfer my data to mongoDb.

16reactions
8q16dcommented, Jul 19, 2020

@cmlbrnc @syedfaizan I had the exact same issue and I finally found out what the issue was by pasting my code into https://next-code-elimination.now.sh/. The issue was that my firebase-admin import wasn’t being eliminated by the client-side, leading to the code being run in the browser and causing this error. In my case, the import wasn’t eliminated because it was unused, so simply using it in getServersideProps fixed the error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Can't resolve 'child_process' - Stack Overflow
// The error appears when I do this import import { GoogleSpreadsheet } from "google-spreadsheet"; const SPREADSHEET_ID = process.env.
Read more >
Discussion on: How-to Read & Write Google Sheets with React
node_modules/google-auth-library/build/src/auth/googleauth.js:17:0. Module not found: Can't resolve 'child_process'
Read more >
[Solved]-Module not found: Can't resolve 'child_process'
The reason is that the library you require uses some nodejs native modules, like path , fs or child_process . As part of...
Read more >
I'm Trying to Inject An NPM package As A Plugin on A Next.js ...
node_modules/google-auth-library/build/src/auth/googleauth.js:17:0 Module not found: Can't resolve 'child_process' Import trace for ...
Read more >
google-auth-library - npm
Google APIs Authentication Client Library for Node.js. ... keysEnvVar) { throw new Error('The $CREDS environment variable was not found!') ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found