0

I am currently trying to integrate a javascript file into an HTML page but I am having difficulties with errors arising when running the page through a node.js server. Specifically, the error is with the following code:

var Twit = require('twit'),
var client = new Twit({
      consumer_key: '',
      consumer_secret: '',
      access_token: '',
      access_token_secret: '',
      timeout_ms: 60*1000,
    }),

The error raise is that require is not a function. To resolve this I moved the above code into app.js but I am now unsure how to include Twit and Client into my javascript file? As the functions within my javascript file now cannot seem to access these variables.

user4357505
  • 135
  • 2
  • 9
  • Can we have the full error message please? – Haych Mar 30 '16 at 16:26
  • Use NPM.. either programically or package.json – Carol Skelly Mar 30 '16 at 16:27
  • error with the code included: ReferenceError: require is not defined, without it it just flags up that the use of twit or client isn't defined – user4357505 Mar 30 '16 at 16:58
  • I think your problem is that you are trying to use Node.js client-side. This question is very similar I think. Trying using Browserify: http://stackoverflow.com/a/19059825/2420327 – Haych Mar 30 '16 at 17:19
  • I think that you should install require : sudo npm install -g require – Art Base Mar 30 '16 at 20:55
  • ideally, you should be doing this on the server. I did a similar thing with my webapp. mean without mongo. Here's the link if it helps https://github.com/binarybaba/influenza – Amin Mohamed Ajani Mar 30 '16 at 20:55

0 Answers0