Skip to content

Builds fail with web3 #457

@odoe

Description

@odoe

Bug / Enhancement

I was trying to use web3 in a Dojo app, but I get some odd errors.

With a vanilla dojo create app --name dojo-web3 --tsx, it will build but throws a runtime error. If I delete the package-lock.json and node_modules, I get a build time error.

Package Version: 7.0 & 7.0.5

Code

import Web3 from 'web3';

import routes from './routes';
import App from './App';

const registry = new Registry();
registerRouterInjector(routes, registry);

// this could be window.ethereum if a wallet browser installed
const web3 = new Web3('ws://localhost:8546');

sample repo

Expected behavior:

I would expect a build without errors and a workflow to build a Dapp with Dojo.

Actual behavior:

// dojo vanilla install
// builds no errors, fails in the browser
util.js:103 Uncaught (in promise) ReferenceError: Buffer is not defined
    at Object../node_modules/core-util-is/lib/util.js (util.js:103)
    at __webpack_require__ (bootstrap:68)
    at Object.<anonymous> (_stream_readable.js:67)
    at Object../node_modules/readable-stream/lib/_stream_readable.js (main.js:49474)
    at __webpack_require__ (bootstrap:68)
    at Object../node_modules/readable-stream/readable-browser.js (readable-browser.js:1)
    at __webpack_require__ (bootstrap:68)
    at Object.<anonymous> (response.js:3)
    at Object../node_modules/stream-http/lib/response.js (response.js:224)
    at __webpack_require__ (bootstrap:68)

// dojo after delete package-lock.json and node_modules and reinstall
./node_modules/stream-browserify/index.js
Module not found: Error: Can't resolve 'readable-stream/duplex.js' in '/home/odoe/dev/block
chain-dev/dojo-web3/node_modules/stream-browserify'
resolve 'readable-stream/duplex.js' in '/home/odoe/dev/blockchain-dev/dojo-web3/node_module
s/stream-browserify'
  Parsed request is a module
  using description file: /home/odoe/dev/blockchain-dev/dojo-web3/node_modules/stream-brows
erify/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      looking for modules in /home/odoe/dev/blockchain-dev/dojo-web3

Node Version: 14.16.0
NPM Version: 6.17.11

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions