Web3 can be installed via npm by simply issuing the following command: $ npm install web3 It can also be directly downloaded from https://github.com/ethereum/web3.js.
This can be found under node_modules, for example, /home/drequinox/netstats/node_modules/web3/dist/web3.js.
Building Decentralized Applications from Scratch (Part 2)
Note that drequinox is specific to the user under which these examples were developed, you will see the user that you are running these commands under.
The file can optionally be copied into the directory where the main application is and can be used from there.
Once the file is successfully referred in HTML or JS, Web3 needs to be initialized by providing an HTTP provider.
This is usually the link to the localhost HTTP endpoint exposed by the running the geth client.
This can be achieved using the following code: web3.setProvider(new web3.providers.HttpProvider(‘http://localhost:8545’)); Once the provider is set, further interaction with the contracts and blockchain can be done using the web3 object and its available methods.
The web3 object can be created using the following code: if (typeof web3 !== ‘undefined’) web3 = new Web3(web3.currentProvider); else web3 = new Web3(new Web3.providers.HttpProvider(“http://localhost:8545”));
Why This Matters for Blockchain Technology
Understanding Installing web3.js is not just an academic exercise — it has real-world implications for how blockchain systems are designed, deployed, and secured. Whether you are a developer building decentralized applications, a business leader evaluating blockchain adoption, or a curious learner exploring the technology, this knowledge provides a critical foundation.
Key Points to Remember
- Installing web3.js Web3 can be installed via npm by simply issuing the following command: $ npm install web3 It can also be directly downloaded from https://github.com/ethereum/web3.js.
- This can be found under node_modules, for example, /home/drequinox/netstats/node_modules/web3/dist/web3.js.
- Note that drequinox is specific to the user under which these examples were developed, you will see the user that you are running these commands under.
- The file can optionally be copied into the directory where the main application is and can be used from there.
Conclusion
Installing web3.js represents one of the many innovative layers that make blockchain technology so powerful and transformative. As distributed systems continue to evolve, a solid understanding of these core concepts becomes increasingly valuable — not just for developers, but for anyone building, investing in, or working alongside blockchain-powered systems.
Whether you are just starting your blockchain journey or deepening existing expertise, mastering these fundamentals gives you the tools to think clearly about decentralized systems and make smarter decisions in this rapidly evolving space.