Skip to content
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

Errors building with webpack #2359

Open
tstibbs opened this issue Sep 10, 2020 · 11 comments
Open

Errors building with webpack #2359

tstibbs opened this issue Sep 10, 2020 · 11 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue. web webpack

Comments

@tstibbs
Copy link

tstibbs commented Sep 10, 2020

#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

@tstibbs
Copy link
Author

tstibbs commented Sep 10, 2020

Note if like me you're not bundling for the browser you can resolve these problems by telling webpack to bundle for node by adding the following to webpack.config.js:

module.exports = {
    target: 'node'
}

That works for me, however I'm leaving this ticket here because it appears there is still a problem if you are genuinely bundling to run in the browser.

@JustinBeckwith JustinBeckwith added type: question Request for information or clarification. Not an issue. web webpack labels Sep 10, 2020
@fhinkel
Copy link
Contributor

fhinkel commented Dec 7, 2020

Greetings, we're closing this. Looks like the issue got resolved. Please let us know if the issue needs to be reopened.

@fhinkel fhinkel closed this as completed Dec 7, 2020
@tstibbs
Copy link
Author

tstibbs commented 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.

@JustinBeckwith JustinBeckwith reopened this Dec 7, 2020
@rossPatton
Copy link

Any progress on this issue? It looks you might be using workspaces, and I'm having a similar problem with trying to get webpack to work with my npm 7 workspaces project

@sofisl
Copy link
Contributor

sofisl commented Aug 4, 2022

I think this was resolved by #2524, but @alexander-fenster will confirm this solution is working.

@TadhgOCP
Copy link

I'm still seeing this issue with Create React App

@AlejandroAkbal
Copy link

I am still seeing the issue with Nuxt 2 and Webpack 4.

@AhmadKerdieh
Copy link

Did anybody find a solution to this. The problem is still persistent if you are trying to bundle for browser.

@chleeab
Copy link

chleeab commented Aug 21, 2023

The problem still there. I am working on web app.

my packages:

  "dependencies": {
    "dotenv": "^16.3.1",
    "firebase": "^9.23.0",
    "googleapis": "^126.0.0",
  },
  "devDependencies": {
    "css-loader": "^6.3.0",
    "html-webpack-plugin": "^5.3.2",
    "style-loader": "^3.3.0",
    "webpack": "^5.51.1",
    "webpack-cli": "^4.8.0"
  }

@PiotrKuzdowicz
Copy link

PiotrKuzdowicz commented Jan 7, 2024

Is anyone working on this issue? I have same problem with react app

@Mark-Asuncion
Copy link

Hello, is there any update on this issue? I also have the same problem with react

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue. web webpack
Projects
None yet
Development

No branches or pull requests