Q
Q
qunaxis2016-08-18 17:08:05
JavaScript
qunaxis, 2016-08-18 17:08:05

Why don't npm modules (request, sugar) work?

When connecting the request and sugar modules, there are no errors, but when trying to use their API (for example, request.get), the exception "TypeError: request.get is not a function" immediately takes off. The same goes for functions from Sugar. What could be the problem and how to fix it? The version of NodeJS is the latest, Windows 10.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2016-08-18
@qunaxis

Isn't that how it works?

var request = require('request');
var Sugar = require('sugar');
Sugar.extend();
var fs = require('fs');

request('http://google.com/doodle.png').pipe(
    fs.createWriteStream('doodle.png')
);
var a = ['a','b','a'];
console.log(a.count('a'));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question