0

I'm currently using node 7.6.0 and am trying the npm request module 2.80.0. The module is installed via package.json npm install. Following their simple example I immediately get: "Failed: Cannot set property 'domain' of undefined". Its a straight copy paste except for the require part.

var request = require('../node_modules/request/request');
request('http://www.google.com', function (error, response, body) {
            console.log('error:', error); // Print the error if one occurred
            console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
            console.log('body:', body); // Print the HTML for the Google homepage.
        });

Am I missing something or is there other dependencies I'm not aware of?

awaken
  • 789
  • 1
  • 11
  • 22

1 Answers1

0

I required it incorrectly. Should just be node_modules/request. Confusing since there is an actual request.js inside the request folder with a module exports.

// Exports

Request.prototype.toJSON = requestToJSON
module.exports = Request
awaken
  • 789
  • 1
  • 11
  • 22