I am adding web3.js according to guide in: Adding web3.js. I traversed steps mentioned there that can be seen below:

enter image description here

There is no problem with "npm" and "meteor" steps but with "pure js" step the following problem occurrs:

enter image description here

That says: dist/web3.min.js : The term 'dist/web3.min.js' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I don't know what is the problem. I have no knowledge about dist/ and don't know the problem's solution. Please help. Thanks

  • Probably it means to download web3.min.js from github into a dist/ directory and include that from your html file.
    – Ismael
    Feb 9 '20 at 17:58

After firing npm install web3 in the terminal you can use web3 library in your project with one of the following ways:

  1. <script src="node_modules/web3/dist/web3.min.js"></script> at the bottom of your html before the </body> tag.
  2. Inside custom javascript file like <script src="index.js"></script> before the </body> tag and then inside of it at the top you can place var Web3 = require('web3');. To make this work you have to use tool like browserify, because require() is feature that is not supported by browsers, but from NodeJS. However if you will be using this javascript file only into NodeJS enviroment you don't have to browserify it.
  3. And again if you will need the web3 library to work on the web you can call again inside custom javascript file, but this time using jQuery library. Example:
$.getScript('node_modules/web3/dist/web3.min.js', function() {
    // logic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.