Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird error 8 object prototype may only be an object or null #634

Closed
Blixia opened this issue Feb 21, 2016 · 4 comments
Closed

Weird error 8 object prototype may only be an object or null #634

Blixia opened this issue Feb 21, 2016 · 4 comments
Labels
bug

Comments

@Blixia
Copy link

@Blixia Blixia commented Feb 21, 2016

I was trying out webtorrent and I got stuck on this error which I can't figure out.

util.js:555
  ctor.prototype = Object.create(superCtor.prototype, {
                          ^
TypeError: Object prototype may only be an Object or null
    at Function.create (native)
    at exports.inherits (util.js:555:27)
    at Object.<anonymous> (/home/frank/Projects/WebTor/Backend/node_modules/webtorrent/node_modules/render-media/node_modules/videostream/mp4-remuxer.js:20:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/frank/Projects/WebTor/Backend/node_modules/webtorrent/node_modules/render-media/node_modules/videostream/videostream.js:4:18)
npm ERR! weird error 8
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! not ok code 0

Installing nodejs-legacy doesn't change this error.

Running the following code:

'use strict';

var webTorrent = require('webtorrent');
var fs = require('fs');

var client = new webTorrent();
var magnet = '';

client.add(magnet,function(torrent)
{
    client.on('torrent',function(torrent)
    {
        console.log(torrent.infoHash);
    });

    torrent.on('done',function()
    {
        console.log('done downloading');
        torrent.files.forEach(function(file)
        {
            file.getBuffer(function(err,buffer)
            {
                if(err) throw err;

                fs.appendFile('./downloads/'+file.name,buffer,function(err)
                {
                    if(err) return console.log(err);
                    console.log('appending');
                })
            });
        });
    });

    torrent.on('download', function(chunkSize)
    {
      console.log('chunk size: ' + chunkSize);
      console.log('total downloaded: ' + torrent.downloaded);
      console.log('download speed: ' + torrent.downloadSpeed);
      console.log('progress: ' + torrent.progress);
      console.log('======');
    });

});
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Feb 22, 2016

This was caused by one of the packages that WebTorrent depends on writing this:

var EventEmitter = require('events')

instead of

var EventEmitter = require('events').EventEmitter

The former only works in very recent versions of node. It's fixed now.

You can fix the issue by updating node, or just reinstalling webtorrent. Cheers!

@feross feross added the bug label Feb 22, 2016
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Feb 22, 2016

Also, it's worth noting that WebTorrent only officially supports node v4 and v5. Since you're probably running 0.10 or 0.12, you should really update!

https://nodejs.org/en/

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Feb 22, 2016

Node 0.10 will be completely unsupported on October 2016. Node 0.12 will be on December 2016. This also means no security updates! 💀

@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 4, 2018

This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue.

@lock lock bot locked as resolved and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.