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.

Errors building with webpack

See original GitHub issue

#1286 and #741 suggest that this module should work with webpack. However, I’m having errors trying to build a simple webpack project.

Environment details

  • OS: Ubuntu 20.04.1 LTS
  • Node.js version: v14.8.0
  • npm version: 6.14.8
  • googleapis version: 59.0.0

Steps to reproduce

  1. Create the files listed below (this is the simplest example I can come up with)
  2. Run npm run build
  3. Observe webpack spitting out errors about how it can’t find lots of modules
package.json:
{
    "dependencies": {
        "googleapis": "59.0.0"
    },
    "devDependencies": {
        "webpack": "4.44.1",
        "webpack-cli": "3.3.12"
    },
    "scripts": {
        "dev": "webpack"
    }
}
src/index.js:
import {google} from 'googleapis'

console.log(google)

Errors output by webpack:

ERROR in ./node_modules/google-auth-library/build/src/auth/googleauth.js
Module not found: Error: Can't resolve 'child_process' in '/workspace/bug/node_modules/google-auth-library/build/src/auth'
 @ ./node_modules/google-auth-library/build/src/auth/googleauth.js 17:24-48
 @ ./node_modules/google-auth-library/build/src/index.js
 @ ./node_modules/googleapis/build/src/index.js
 @ ./src/index.js

ERROR in ./node_modules/google-auth-library/build/src/auth/googleauth.js
Module not found: Error: Can't resolve 'fs' in '/workspace/bug/node_modules/google-auth-library/build/src/auth'
 @ ./node_modules/google-auth-library/build/src/auth/googleauth.js 18:11-24
 @ ./node_modules/google-auth-library/build/src/index.js
 @ ./node_modules/googleapis/build/src/index.js
 @ ./src/index.js

etc etc
Full error output

ERROR in ./node_modules/google-p12-pem/build/src/index.js
Module not found: Error: Can't resolve 'fs' in '/workspace/bug/node_modules/google-p12-pem/build/src'
@ ./node_modules/google-p12-pem/build/src/index.js 10:11-24
@ ./node_modules/gtoken/build/src/index.js
@ ./node_modules/google-auth-library/build/src/auth/jwtclient.js
@ ./node_modules/google-auth-library/build/src/index.js
@ ./node_modules/googleapis/build/src/index.js
@ ./src/index.js

ERROR in ./node_modules/googleapis-common/build/src/discovery.js
Module not found: Error: Can't resolve 'fs' in '/workspace/bug/node_modules/googleapis-common/build/src'
@ ./node_modules/googleapis-common/build/src/discovery.js 16:11-24
@ ./node_modules/googleapis-common/build/src/index.js
@ ./node_modules/googleapis/build/src/index.js
@ ./src/index.js

ERROR in ./node_modules/gtoken/build/src/index.js
Module not found: Error: Can't resolve 'fs' in '/workspace/bug/node_modules/gtoken/build/src'
@ ./node_modules/gtoken/build/src/index.js 10:11-24
@ ./node_modules/google-auth-library/build/src/auth/jwtclient.js
@ ./node_modules/google-auth-library/build/src/index.js
@ ./node_modules/googleapis/build/src/index.js
@ ./src/index.js

ERROR in ./node_modules/googleapis-common/build/src/http2.js
Module not found: Error: Can't resolve 'http2' in '/workspace/bug/node_modules/googleapis-common/build/src'
@ ./node_modules/googleapis-common/build/src/http2.js 16:14-30
@ ./node_modules/googleapis-common/build/src/apirequest.js
@ ./node_modules/googleapis-common/build/src/index.js
@ ./node_modules/googleapis/build/src/index.js
@ ./src/index.js

ERROR in ./node_modules/https-proxy-agent/dist/agent.js
Module not found: Error: Can't resolve 'net' in '/workspace/bug/node_modules/https-proxy-agent/dist'
@ ./node_modules/https-proxy-agent/dist/agent.js 15:30-44
@ ./node_modules/https-proxy-agent/dist/index.js
@ ./node_modules/gaxios/build/src/gaxios.js
@ ./node_modules/gaxios/build/src/index.js
@ ./node_modules/google-auth-library/build/src/transporters.js
@ ./node_modules/google-auth-library/build/src/index.js
@ ./node_modules/googleapis/build/src/index.js
@ ./src/index.js

ERROR in ./node_modules/https-proxy-agent/dist/agent.js
Module not found: Error: Can't resolve 'tls' in '/workspace/bug/node_modules/https-proxy-agent/dist'
@ ./node_modules/https-proxy-agent/dist/agent.js 16:30-44
@ ./node_modules/https-proxy-agent/dist/index.js
@ ./node_modules/gaxios/build/src/gaxios.js
@ ./node_modules/gaxios/build/src/index.js
@ ./node_modules/google-auth-library/build/src/transporters.js
@ ./node_modules/google-auth-library/build/src/index.js
@ ./node_modules/googleapis/build/src/index.js
@ ./src/index.js

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
tstibbscommented, Dec 7, 2020

@fhinkel the issue is resolved when bundling for node, but not when bundling for the browser. I’ll leave it to the project maintainers whether they’d rather have bug reports in an ‘open’ or ‘closed’ state, but afaics the issue still exists.

0reactions
TadhgOCPcommented, Oct 21, 2022

I’m still seeing this issue with Create React App

Read more comments on GitHub >

github_iconTop Results From Across the Web

How I solved and debugged my Webpack issue through trial ...
When webpack bundles your source code, it can become difficult to track down errors and warnings to their original location.
Read more >
Webpack build error - node.js - Stack Overflow
You can use the npm ls --depth=0 to list the installed packages for a project. Run it on PC_A and PC_B, then compare...
Read more >
This will make you more efficient at debugging Webpack ...
In this article we'll build a very primitive plugin for Webpack and then I'll show you how to find out if this plugin...
Read more >
next build fails with webpack error #25276 - GitHub
When attempting to do a build with next build I get the following error. With next 10.2.0, the error does not appear. info...
Read more >
Make Webpack exit on compilation errors - Medium
Upon seeing an error, Webpack causes the pipeline process to hang, and developers are left wondering why the build hasn't finished in over ......
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