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:" compilation error for modules (stream, http, https, constants, zlib_bindings)

See original GitHub issue

Describe the bug I wanted to make use of an npm package “ccxt”. When importing it in a component/module or anywhere in the project I get the following errors:

Codepen/jsFiddle/Codesandbox (required)

  • not sure if this is possible with an error relaed to webpack5 and 3rd party library.

To Reproduce Steps to reproduce the behavior:

  1. initialize project
  quasar create my_new_app
  yarn add ccxt
  1. add import 'ccxt' or var ccxt = require ('ccxt') to any javascript/vue file
  2. quasar dev
  3. See error:
quasar dev

 Dev mode.......... spa
 Pkg quasar........ v2.0.0
 Pkg @quasar/app... v3.0.0
 Pkg webpack....... v5
 Debugging......... enabled

 Configured browser support (>= 87.60% of global marketshare):
 · Chrome for Android >= 91
 · Firefox for Android >= 89
 · Android >= 91
 · Chrome >= 81
 · Edge >= 88
 · Firefox >= 80
 · iOS >= 11.0-11.2
 · Opera >= 72
 · Safari >= 11.1


 App • ⚠️  ️️Setting port to closest one available: 8081

 App • Chaining "UI" Webpack config
 App •  WAIT  • Compiling of "UI" in progress...
 App •  DONE  • "UI" compiled with errors • 10403ms



 App •  ERROR  •  UI  in ./node_modules/ccxt/js/static_dependencies/node-fetch/index.js

Module not found: Can't resolve imported dependency "stream"
Did you forget to install it? You can run: yarn add stream

 App •  ERROR  •  UI  in ./node_modules/ccxt/js/static_dependencies/node-fetch/index.js

Module not found: Can't resolve imported dependency "http"
Did you forget to install it? You can run: yarn add http

 App •  ERROR  •  UI  in ./node_modules/ccxt/js/static_dependencies/node-fetch/index.js

Module not found: Can't resolve imported dependency "https"
Did you forget to install it? You can run: yarn add https

 App •  ERROR  •  UI  in ./node_modules/ccxt/js/static_dependencies/node-rsa/schemes/pkcs1.js

Module not found: Can't resolve imported dependency "constants"
Did you forget to install it? You can run: yarn add constants

 App •  ERROR  •  UI  in ./node_modules/zlib/lib/zlib.js

Module not found: Can't resolve imported dependency "./zlib_bindings"


 App •  COMPILATION FAILED  • Please check the log above for details.

Issues checking in progress...
No issues found.

Expected behavior App should compile,

Platform (please complete the following information): Quasar Version: @quasar/app Version: v2.0.0

Quasar mode:

  • SPA
  • SSR
  • PWA
  • Electron
  • Cordova
  • Capacitor
  • BEX

Tested on:

  • SPA
  • SSR
  • PWA
  • Electron
  • Cordova
  • Capacitor
  • BEX

OS: Ubuntu 20.04 Node: v14.17.1 NPM: 6.14.13 Yarn: 1.22.5

Additional context

I think this is a quasar/webpack5 issue, as there are other projects which can make use of ccxt through yarn/npm + vue. I successfully compiled this one here for example:

https://github.com/MoiOcanas/vue-ccxt

I suspect its something in the webpack configuration. Here are some possibly related issues

https://github.com/ethers-io/ethers.js/issues/998 https://jahed.dev/2021/02/06/upgrading-to-webpack-5/

The last one sounds like it has something to do with webpack v4 automatic polyfills?

I am not an expert on this. But any help on how to configure quasar/webpack5 in order to get rid of the above errors would be appreciated!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
yeuscommented, Jun 24, 2021

@hawkeye64 thx, that helped, finally got it compiling. FOr those who have a similar problem, I had to extend the chainWebPack in quasar.conf.js like this:

  chainWebpack (chain) {
    // this is in order to support the not-updated version of ccxt:
    // also needs: 
    //    yarn add --dev node-polyfill-webpack-plugin browserify-zlib
    const nodePolyfillWebpackPlugin = require('node-polyfill-webpack-plugin')
    chain.plugin('node-polyfill').use(nodePolyfillWebpackPlugin)
    chain.resolve.alias.set('zlib', 'browserify-zlib')
  },
1reaction
rstoenescucommented, Jun 23, 2021

This is due to Webpack 5 not shipping with nodejs polyfills anymore. Explanation is found on the upgrade guide (along with a solution): https://quasar.dev/start/upgrade-guide#nodejs-polyfills

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error: Can't resolve 'zlib' - Stack Overflow
Knowing that: before I start migration my project worked fine. npm version: 6.14.11. node version: 14.16.0. I've tried to hit npm install zlib ......
Read more >
How to fix 'Module not found: Can't resolve 'http' in ... - YouTube
... 'react-scripts' to 4.0.2 in your package.json and run `npm install` again :D Follow me on Twitter: https ://twitter.com/jacobmtucker?
Read more >
error: can't resolve 'zlib' | The AI Search Engine You Control
Module not found : Can't resolve 'zlib_bindings' in next.js when trying to connect ... resolve errors (crypto, fs, http, https, net, path, stream,...
Read more >
/Releases.md | std@0.170.0 | Deno
Revert "fix(node/http): do not buffer first chunk (#2989)" (#3013) ... when the response stream throws an error (#3008); fix(node): add missing exports to ......
Read more >
What's New | Oracle, Software. Hardware. Complete.
libguestfs-1.40.2-28.0.4.module+el8.7.0+20889+ec3df884 - Access and modify virtual ... Oracle Cloud Infrastructure(OCI) Modules for PowerShell (Update) ...
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