4

I want to use web3 from loginmain.js file. My project hierarchy looks like:

Project/
  www/
    login.html
    js/
      login.js
      app/
        loginmain.js
      lib/
        jquery.js
        web3.js
  tools/

my loginmain.js file :

define(function (require) {
var $ = require('jquery'),
    Web3 = require('web3'),
    lib = require('./lib'),
    controller = require('./controller/c1'),
    model = require('./model/m1');

//A fabricated API to show interaction of
//common and specific pieces.
var web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8000'));
console.log(web3);
controller.setModel(model);
$(function () {
    controller.render(lib.getBody());
});});

I get the following Error

TypeError: Web3 is undefined 

Any idea how can I solve it ?

3

I propose you to read about how to load an external js library in a js file : https://stackoverflow.com/questions/950087/how-to-include-a-javascript-file-in-another-javascript-file

this issue doesn't have a direct relation with web3.js

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.