Web3.js: Loading web3.min.js in browser fails with "require is not defined"

Created on 5 Dec 2019  路  5Comments  路  Source: ChainSafe/web3.js

I've installed [email protected] with npm install.
I copied the file node_modules/web3/dist/web3.min.js into my web app.
I'm loading the file with:

<script type="text/javascript" src="js/web3.min.js"></script>

In the browser console (Chrome 70+), I see this error:

Uncaught ReferenceError: require is not defined
    at web3.js:1
1.x CI QA bug

Most helpful comment

v1.2.2 is ok without this error.

All 5 comments

Thanks for opening this issue! The minified file here provided in the GitHub repository does work as expected but the published one in the web3 package not. We will publish a new fixed minified file on the next patch release. I apologize for all the trouble you might have.

v1.2.2 is ok without this error.

@nivida Where is the minified file? The one in the ZIP archive https://github.com/ethereum/web3.js/releases/tag/v1.2.4 has the same problem.

v1.2.2 works for me.

@digulla Thanks for asking this! The minified file can be found here.

@nivida Still getting the same error with the file at your link.
sha256 of the file:

42037f35ccf2195cdd80448f4963515dd8c6a2d7b416f042743c1d4cec7fc17d  web3.min.js
Was this page helpful?
0 / 5 - 0 ratings