Skip to content

./src/utils/web3.js Module not found: Can't resolve 'web3' #5

Description

@Sathish-Prabhu

After executing the npm start command, The localhost starts and after a few seconds this error pops up.

import Web3 from 'web3'

let web3

// Checking if Web3 has been injected by the browser (Mist/MetaMask)
if (typeof window !== 'undefined' && typeof window.web3 !== 'undefined') {
// Use Mist/MetaMask's provider.
web3 = new Web3(window.web3.currentProvider)
console.log('Injected web3 detected.')
} else {
// Fallback to localhost if no web3 injection. We've configured this to
// use the development console's port by default.
const provider = new Web3.providers.HttpProvider('http://127.0.0.1:8545')
web3 = new Web3(provider)
console.log('No web3 instance injected, using Local web3.')
}

export default web3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions