Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Module not found: Can't resolve 'util' #90

@navono

Description

@navono

Description

I create a app with create-react-app with --typescript, and add some lib to it. But when I execute start script, a compilation error has occurred:

Failed to compile.

./node_modules/browserify-zlib/lib/index.js
Module not found: Can't resolve 'util' in 'E:\sourcecode\frontend\AppDev-web\node_modules\browserify-zlib\lib'

I'm not explicit import browserify-zlib, so I search it in project, in yarn.lock file, I found this:

node-libs-browser@^2.0.0:
  version "2.2.0"
  resolved "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.0.tgz#c72f60d9d46de08a940dedbb25f3ffa2f9bbaa77"
  integrity sha512-5MQunG/oyOaBdttrL40dA7bUfPORLRWMUJLQtMg7nluxUvk5XwnLdL9twQHFAjRx/y7mIMkLKT9++qPbbk6BZA==
  dependencies:
    assert "^1.1.1"
    browserify-zlib "^0.2.0"
    buffer "^4.3.0"
    console-browserify "^1.1.0"
    constants-browserify "^1.0.0"
    crypto-browserify "^3.11.0"
    domain-browser "^1.1.1"
    events "^3.0.0"
    https-browserify "^1.0.0"
    os-browserify "^0.3.0"
    path-browserify "0.0.0"
    process "^0.11.10"
    punycode "^1.2.4"
    querystring-es3 "^0.2.0"
    readable-stream "^2.3.3"
    stream-browserify "^2.0.1"
    stream-http "^2.7.2"
    string_decoder "^1.0.0"
    timers-browserify "^2.0.4"
    tty-browserify "0.0.0"
    url "^0.11.0"
    util "^0.11.0"
    vm-browserify "0.0.4"
  • I tried add util package, still not work
  • I tried add util in webpack.config.js like this:
    node: {
      util: 'empty',
      module: 'empty',
      dgram: 'empty',
      dns: 'mock',
      fs: 'empty',
      net: 'empty',
      tls: 'empty',
      child_process: 'empty',
    },

still not work

Info

create-react-app: version: 2.1.8
webpack.config.js
package.json
tsconfig.json

Anybody know anything about this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions