A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/browserify/commonjs-assert/issues/55 below:

process is not defined, won't build in Webpack · Issue #55 · browserify/commonjs-assert · GitHub

I tried building this in my project with latest webpack and got the following error:

Uncaught ReferenceError: process is not defined,

Seems like webpack is hitting a require('util/') and bundling Node.js's implementation of util, which has Node.js only code, hence the error above.

I stripped it down to a simple test case.

webpack.config.js
const path = require('path');

module.exports = {
  mode : "development",
  entry : { main: "./entry.js" },
  output : {
    path : path.resolve(__dirname, "dist"),
    filename : "[name].js",
    library : "datadesk",
    libraryTarget : "umd"
  },
  resolve: {
    fallback: {
      assert: require.resolve("assert"),
    }
  },
  devtool: "source-map"
};
entry.js
const a = require('assert');
package.json
{
  "name": "testtt",
  "version": "1.0.0",
  "dependencies": {
    "assert": "^2.0.0",
    "webpack": "^5.65.0"
  },
  "devDependencies": {
    "webpack-cli": "^4.9.1"
  }
}
testtt.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="./dist/main.js"></script>
  </head>
  <body>
  </body>
</html>

Also here's the built files. You can copy and run something like python -m http.server to open, or another small http file server.

testtt.zip

I think this can be worked around by also polyfilling util in the webpack config, but there is no util-browserify package that I've found yet on npm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4