Nodejs zlib throwing a no method error - node.js

I just installed the ebay-api package through npm. One of it's dependencies is restler and it's throwing an error that I can't seem to fix.
TypeError: Object #<Object> has no method 'gunzip'
at IncomingMessage.<anonymous> (node_modules/restler/lib/restler.js:428:10)
at EventEmitter._decode (node_modules/restler/lib/restler.js:161:25)
at IncomingMessage.<anonymous> (node_modules/restler/lib/restler.js:140:14)
at IncomingMessage.emit (events.js:88:20)
at HTTPParser.onMessageComplete (http.js:137:23)
at CleartextStream.ondata (http.js:1125:24)
at CleartextStream._push (tls.js:363:27)
at SecurePair.cycle (tls.js:679:20)
at EncryptedStream.write (tls.js:122:13)
at Socket.ondata (stream.js:38:26)
Line 428 is:
zlib.gunzip(buf, callback);
I'm running node v0.5.11-pre and the most up-to-date restler install as well. Any help here would be greatly appreciated.

Node 0.5.11-pre does not have the zlib helper method gunzip.
The current stable version of restler is >= 0.6.0 unfortunately.
You may be able to patch that method on the Node module, but there may very well be other issues. Would upgrading to a stable version of Node be reasonable for you? Even if just to 0.6.0, which should be very similar to 0.5.11-pre.

Related

karma-init fails on Windows 10 with Node.js 7.1.0 x64

After installing succesfully the following node packages:
karma
karma-jasmine
karma-chrome-launcher
jasmine-core
I get the following error when executing karma-init:
C:\Projects\SocialMeal>karma init
events.js:160
throw er; // Unhandled 'error' event
^
Error: write EINVAL
at exports._errnoException (util.js:1022:11)
at WriteStream.Socket._writeGeneric (net.js:715:26)
at WriteStream.Socket._write (net.js:734:8)
at doWrite (_stream_writable.js:334:12)
at writeOrBuffer (_stream_writable.js:320:5)
at WriteStream.Writable.write (_stream_writable.js:247:11)
at WriteStream.Socket.write (net.js:661:40)
at Interface._writeToOutput (readline.js:256:17)
at Interface._insertString (readline.js:406:12)
at Interface._ttyWrite (readline.js:933:18)
at Interface.write (readline.js:352:24)
Any clues?
After some time I found it.
It seems like an Node.js 7.1.0 issue. It happens with newer Node.js versions (<7.0.0) as posted here:
https://github.com/nodejs/node/issues/9542
Until they fix this issue you need to uninstall your node.js and install an older version (e.g.: 6.9.1) in order to make ir work.

Number.isInteger method and Node.js version

Using Node.js 4.5.0 I got the expected behaviour
> console.log(Number.isInteger(42))
true
but using Node.js 0.10.36 I got the error
> console.log(Number.isInteger(42))
TypeError: Object function Number() { [native code] } has no method 'isInteger'
How I know which is the minimal version of Node.js required for using the
Number.isInteger method?
I couldn't find any related information after grepping Node.js CHANGELOG files.
Edit 1: node.green shows that the method is supported from Node.js 0.12.16.
Edit 2: Neither could I find any related information in V8 CHANGELOG.
As they recommend to look after in their docs, Number.isInteger is supported in version 0.12.16. Though that's not the minimum version, which might be 0.12.3 which uses the same v8 engine version.
Edit #1: In this commit V8 3.24.11 was released, but Node.js only made use of V8 3.25.30.0 in version 0.11.13. Furthermore, I made some tests (in Xubuntu 16.04):
Node.js v0.11.13 (V8 3.25.30.0)
> Number.isInteger(42)
true
Node.js v0.11.12 (V8 3.22.24.19)
> Number.isInteger(42)
TypeError: Object function Number() { [native code] } has no method 'isInteger'
at repl:1:8
at REPLServer.defaultEval (repl.js:130:27)
at bound (domain.js:255:14)
at REPLServer.runBound [as eval] (domain.js:268:12)
at REPLServer.<anonymous> (repl.js:277:12)
at REPLServer.EventEmitter.emit (events.js:104:17)
at REPLServer.Interface._onLine (readline.js:202:10)
at REPLServer.Interface._line (readline.js:531:8)
at REPLServer.Interface._ttyWrite (readline.js:806:14)
at ReadStream.onkeypress (readline.js:101:10)
Notice that in Node.js v0.11.12, V8 3.22.24.19 is lower than 3.24.11 which is when they added Number.isInteger. So, in conclusion, Node.js v0.11.13 is the minimal version that has method 'isInteger'.
Number.isInteger() was added in V8 3.26.30 (see this commit pointed out here), so the minimal version of Node.js supporting this method is 0.12.0.
Number.isInteger() is defined in ES6; it requires a Node version that implements ES6.

Error to create meanjs project with yo Generator

I am beginner to means js ,I did the setup for meanjs from here.
I have use the following commands to create meanjs project with some question answering.
santosh#santosh:~/Documents/Projects$ yo meanjs
Native thread-sleep not available.
This will result in much slower performance, but it will still work.
You should re-install spawn-sync or upgrade to the lastest version of node if possible.
Check /usr/local/lib/node_modules/yo/node_modules/yeoman-environment/node_modules/inquirer/node_modules/external-editor/node_modules/spawn-sync/error.log for more details
Native thread-sleep not available.
This will result in much slower performance, but it will still work.
You should re-install spawn-sync or upgrade to the lastest version of node if possible.
Check /usr/local/lib/node_modules/yo/node_modules/tabtab/node_modules/inquirer/node_modules/external-editor/node_modules/spawn-sync/error.log for more details
You're using the official MEAN.JS generator.
? What mean.js version would you like to generate? 0.4.0
0.4.0
? In which folder would you like the project to be generated? This can be chang
ed later. mytest
Cloning the MEAN repo.......
? What would you like to call your application? MEAN
? How would you describe your application? Full-Stack JavaScript with MongoDB,
Express, AngularJS, and Node.js
? How would you describe your application in comma seperated key words? MongoDB
, Express, AngularJS, Node.js
? What is your company/author name? santosh
? Would you like to generate the article example CRUD module? Yes
? Would you like to generate the chat example module? Yes
Running npm install for you....
This may take a couple minutes.
Error: stderr maxBuffer exceeded.
at Socket.<anonymous> (child_process.js:686:13)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at Pipe.onread (net.js:526:21)
santosh#santosh:~/Documents/Projects$
Please tell me why Error: stderr maxBuffer exceeded. are there ?
The problem is most likely related with old Node.js and NPM packages. Update those and the problem should disappear.
A similar problem was solved here.

TypeError: require is not a function at Object.module.exports.map

while compiling node js project with gulp commmand below error occurs.
In public/js/app/app.node.js:
var fs = require('fs');
^
TypeError: require is not a function at Object.module.exports.map../file
I tried to implement react flux api calls with current project.
UPDATE:
this error has been removed after adding
new dwebpack.DefinePlugin({ "global.GENTLY": false })
but currently below error occuring.
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/types/mime.types'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at Mime.load
answering own question is not right way to do it but as it will be helpful for other and as people look for answered question also so doing this.
as my issue with related to node version.
i am on latest node version 4.0.0 and having issue with it.
so installed lower node version 0.12.7(which was specified in package.json of template code) and rebuilt by npm install solved it.
i have used https://www.npmjs.com/package/n package to install multiple node version and selecting the one i wanted to use.

moment-isocalendar not working

According to their documentation, all one needs to do is require the moment-isocalendar module.
This does not work:
var m = require("moment");
var i = require("moment-isocalendar");
m().isocalendar();
It throws
TypeError: Object Tue Aug 13 2013 18:20:36 GMT+0300 has no method 'isocalendar'
at repl:1:6
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:98:17)
at emitKey (readline.js:1095:12)
I looked at the module (all were installed with npm), and it requires the "moment" and monkey-patches it. I tried requiring the moment-isocalendar before the moment module, but got the same result. The moment-isocalendar is an empty object after the monkey-patch {}.
Has anyone used a momentjs plugin in nodejs before? Any ideas how to make this work?
Later edit
It works in nodejs v0.10.12, it doesn't work in nodejs v0.10.15. I added an answer.
Later edit
I'm running Ubuntu 13.04 with 3.8.0-26-generic kernel, and the nodejs is installed via package manager from ppa:chris-lea/node.js
moment-isocalendar is a plugin, not part of the main moment.js library. My guess is that they didn't update it for the last moment.js release, but I have not verified this.
You should raise an issue here: https://github.com/fusionbox/moment-isocalendar
After a little research, the answer is simple: it is not working. It was relying on an older nodejs feature (bug) where you could monkey-patch the in-memory modules after their first require, which apparently doesn't work anymore (worked in 0.10.12, doesn't work in 0.10.15).
If anyone gets the module as-is working i'll change the right answer.

Resources