PetrosM
PetrosM

Reputation: 251

Uncaught ReferenceError: require is not defined in Meteor

I am trying to deploy my project which needs the web3 Javascript API. As done by some examples I found online, I need to do the following:

<script type="text/javascript">
var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545"));
...code... </script>

When I run the project i get this error "Uncaught ReferenceError: require is not defined". I've already done "meteor add modules", meteor add aramk:requirejs, sudo npm install require and sudo npm install requirejs. I downloaded and included the js file (through templating since in meteor js files are handled differently). What am I missing?

Upvotes: 2

Views: 533

Answers (1)

kkkkkkk
kkkkkkk

Reputation: 7748

I see that you use require inside a script tag so I think this code is in a html file. If that's so, you will need to move that code to a js file because require can not be used in html file.

Upvotes: 3

Related Questions