googleapis / googleapis/google-api-nodejs-client

Errors building with webpack

Open
#2,359 11 comments 1 reaction 1 assignee Claimed by @sofisl View on GitHub
type: question web webpack
Dominant language
TypeScript
Stars
12.2k
Forks
2k
Avg merge
1d 9h
Merged PRs (30d)
24

Description

#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:
```json
{
"dependencies": {
"googleapis": "59.0.0"
},
"devDependencies": {
"webpack": "4.44.1",
"webpack-cli": "3.3.12"
},
"scripts": {
"dev": "webpack"
}
}
```

##### src/index.js:
```javascript
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

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.