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

Modules "net" and "tls" not found when running webpack under sheets API directory #1732

Closed
cwysong85 opened this issue Jun 12, 2019 · 5 comments · Fixed by #1742
Closed

Modules "net" and "tls" not found when running webpack under sheets API directory #1732

cwysong85 opened this issue Jun 12, 2019 · 5 comments · Fixed by #1742
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. web

Comments

@cwysong85
Copy link

Environment details

  • OS: Windows 10 Pro v10.0.17134
  • Node.js version: 10.16.0
  • npm version: 6.9.0
  • googleapis version: 40.0.0

Steps to reproduce

  1. cd src/apis/sheets
  2. npm install
  3. npm run webpack

If you are running the environment versions above, the webpack compilation should error out.

λ npm run webpack

> @google/[email protected] webpack C:\Users\corey\google-api-nodejs-client\src\apis\sheets
> webpack

Hash: 4f6e54b109b233b15a5a
Version: webpack 4.33.0
Time: 3324ms
Built at: 06/12/2019 11:21:08 AM
 3 assets
Entrypoint main = sheets.min.js
  [3] (webpack)/buildin/global.js 472 bytes {0} [built]
 [39] crypto (ignored) 15 bytes {0} [built]
 [87] ./index.ts 1.06 KiB {0} [built]
 [95] util (ignored) 15 bytes {0} [built]
 [97] util (ignored) 15 bytes {0} [built]
[106] (webpack)/buildin/module.js 497 bytes {0} [built]
[177] ./v4.ts 24.4 KiB {0} [built]
    + 171 hidden modules

ERROR in ./node_modules/https-proxy-agent/index.js
Module not found: Error: Can't resolve 'net' in 'C:\Users\corey\google-api-nodejs-client\src\apis\sheets\node_modules\https-proxy-agent'
 @ ./node_modules/https-proxy-agent/index.js 5:10-24
 @ ./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-common/build/src/index.js
 @ ./index.ts

ERROR in ./node_modules/https-proxy-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'C:\Users\corey\google-api-nodejs-client\src\apis\sheets\node_modules\https-proxy-agent'
 @ ./node_modules/https-proxy-agent/index.js 6:10-24
 @ ./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-common/build/src/index.js
 @ ./index.ts
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @google/[email protected] webpack: `webpack`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @google/[email protected] webpack script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\corey\AppData\Roaming\npm-cache\_logs\2019-06-12T15_21_08_768Z-debug.log

Steps to fix

  1. edit webpack.config.js
  2. Add net: 'empty' and tls: 'empty' to the node section:
  node: {
    child_process: 'empty',
    fs: 'empty',
    crypto: 'empty',
    net: 'empty',
    tls: 'empty'
  },
  1. npm run webpack should now work.

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jun 13, 2019
@sduskis sduskis added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed triage me I really want to be triaged. labels Jun 16, 2019
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Jun 16, 2019
@alexander-fenster alexander-fenster self-assigned this Jun 17, 2019
@yoshi-automation yoshi-automation removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Jun 17, 2019
@JustinBeckwith JustinBeckwith added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Jun 17, 2019
@bcoe
Copy link
Contributor

bcoe commented Jun 18, 2019

@cwysong85 I'm glad you've found a work around 👍 we're in the process of looking into fixing this upstream (so that the workaround could be avoided).

I've also created a tracking ticket to add integration tests (to prevent these sorts of regressions).

@alexander-fenster
Copy link
Contributor

So the fun thing is that I can't repro this on Linux and you're apparently doing this on Windows. I wonder if it might the reason why the regular expressions fail in webpack.config.js tests (the https-proxy-agent should be ignored alltogether and replaced with a null-module).

I'll try to repro on Windows machine, and if it reproduces, I'll fix the config. For now, @cwysong85, would it be possible for you to try running npm run webpack on Linux or Mac and let us know if it works for you there?

@ghost
Copy link

ghost commented Jul 9, 2020

thank man, very help

@watermirror1107
Copy link

webpack.config.js this file add a options "target:'node'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. web
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants
@sduskis @bcoe @JustinBeckwith @cwysong85 @alexander-fenster @watermirror1107 @yoshi-automation and others